Need help with simple vba script for Excel macro

Status
Not open for further replies.

smileygladhands

In Runtime
Messages
499
I have a column for about 4000 accounts on Excel. Each of them needs to have ('0 ) - without the parenthesis - added to the beginning of the account. I tried recording a macro that recorded me selecting the beginning of the text in the cell and typing '0. However, when I run the macro on other cells it replaces the new account number with all of the text of the cell that I recorded the macro in.
Here's the script:

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Sub add_0()
'
' add_0 Macro
' Macro recorded 07/12/2005 by a371261
'
' Keyboard Shortcut: Ctrl+q
'
ActiveCell.FormulaR1C1 = "'069049000"
Range("C11").Select
End Sub
Sub Macro7()
'
' Macro7 Macro
' Macro recorded 07/12/2005 by a371261
'
' Keyboard Shortcut: Ctrl+t
'
Application.CommandBars("Stop Recording").Visible = False
Application.WindowState = xlMinimized
Application.Goto Reference:="add_0"
End Sub
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Obviously, I'm not very proficient with vbase... how can I edit the above so when I highlight the rest of the cells, it places '0 at the beginning of each account number?

Thanks for any help.
:confused:
 
the way i would do it is make it check if there's something in the cell. if there is, then cut the contents out. then add the 0 you want, then paste it back. then move to the cell below it. and repeat the process (use a do while selected cell <> "" ) .
should work.
 
Status
Not open for further replies.
Back
Top Bottom