Excel: Calling all Microsoft Excel Experts
Excel: Calling all Microsoft Excel Experts
Author
Discussion

stone

Original Poster:

1,538 posts

271 months

Tuesday 3rd August 2004
quotequote all
I have a spreadsheet with a column of data with approx 800 rows. I need to add an X as the first character in each of the cells. Any experts advise as to the easiest way of adding this.

wiggy001

7,066 posts

295 months

Tuesday 3rd August 2004
quotequote all
stone said:
I have a spreadsheet with a column of data with approx 800 rows. I need to add an X as the first character in each of the cells. Any experts advise as to the easiest way of adding this.


If your data is in cells A1 to A800, in cell B1 type:

=CONCATENATE("X",A1)

Copy this down to cell B800 and Robert is your father's brother.

pdV6

16,442 posts

285 months

Tuesday 3rd August 2004
quotequote all
In Tools->Macro->VB Editor, create the following routine and run it (remembering to change the starting values accordingly)

Macro said:

Sub MacroX()

Dim Col As String, RowStart As Integer, RowEnd As Integer, i As Integer
Col = "B" 'Change this to your column
RowStart = 1 ' Change this to your 1st row
RowEnd = 5 ' change this to your last row

For i = RowStart To RowEnd
Range(Col & CStr(i)).Select
ActiveCell.FormulaR1C1 = "X" & ActiveCell.FormulaR1C1
Next i
End Sub

bga

8,134 posts

275 months

Tuesday 3rd August 2004
quotequote all
wiggy001 said:

stone said:
I have a spreadsheet with a column of data with approx 800 rows. I need to add an X as the first character in each of the cells. Any experts advise as to the easiest way of adding this.



If your data is in cells A1 to A800, in cell B1 type:

=CONCATENATE("X",A1)

Copy this down to cell B800 and Robert is your father's brother.


Alternatively in B1 you can enter ="X"&A1 which will save having to type a long word Still need to copy to all cells though.

If you want to keep it you can:

1.highlight the column
2.edit -> copy
3.edit -> paste special
4.paste as values

which will remove the formula.

Prefer macro though. Why take 2 mins to do a task when you can spend 15 writing a macro!

stone

Original Poster:

1,538 posts

271 months

Tuesday 3rd August 2004
quotequote all
Thanks!!

pdV6

16,442 posts

285 months

Tuesday 3rd August 2004
quotequote all
bga said:

Prefer macro though. Why take 2 mins to do a task when you can spend 15 writing a macro!

Took about 30 sec!

wiggy001

7,066 posts

295 months

Wednesday 4th August 2004
quotequote all
bga said:
Alternatively in B1 you can enter ="X"&A1 which will save having to type a long word


True... why use a long word when a diminutive one will do?

Fer

7,765 posts

304 months

Wednesday 4th August 2004
quotequote all
New request. I have a spreadsheet with several workbooks, built from an extract from Alterian.

Any hints for a macro to go through each workbook, and save it as HTML in a file with the same name as the workbook.

Answers on a postcard to the usual address. TIA.

pdV6

16,442 posts

285 months

Wednesday 4th August 2004
quotequote all
Sub SaveHTML()
Dim i As Integer
For Each Sheet In ActiveWorkbook.Sheets
i = i + 1
ActiveWorkbook.PublishObjects.Add(xlSourceSheet, "C:\Temp\" & Sheet.Name & ".htm", Sheet.Name, "", xlHtmlStatic, "Test" & CStr(i), "").Publish (True)
Next
End Sub


>> Edited by pdV6 on Wednesday 4th August 15:43

Fer

7,765 posts

304 months

Wednesday 4th August 2004
quotequote all
pdV6 said:
Sub SaveHTML()
Dim i As Integer
For Each Sheet In ActiveWorkbook.Sheets
i = i + 1
ActiveWorkbook.PublishObjects.Add(xlSourceSheet, "C:Temp" & Sheet.Name & ".htm", Sheet.Name, "", xlHtmlStatic, "Test" & CStr(i), "").Publish (True)
Next
End Sub




Thanks Pete. That's another PH I owe.

bga

8,134 posts

275 months

Wednesday 4th August 2004
quotequote all
pdV6 said:

bga said:

Prefer macro though. Why take 2 mins to do a task when you can spend 15 writing a macro!


Took about 30 sec!


macro man to the rescue

pdV6

16,442 posts

285 months

Wednesday 4th August 2004
quotequote all
bga said:

macro man to the rescue



Easiest way to get started on XL Macros is to simply record what you want to do and then go and look to see what it created for you. Simple to then adapt it as necessary.