Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to use the code?
Hi Patrick Thanks for giving me the formula to add 99 before the digit its working perfectly but i could not make use of the code which you hav esuggested, i have inserted the code by right clicking the sheet1- viewcode and pasted the code but i could not able to run the macro. So please help as im new to excel. The code is: dim cell as range dim text as string set cell = range("A1") do until isempty(cell) text = cell.value cell.value = LEFT("990000000000",12 - len(text) ) & text set cell = cell.offset(1) loop -- Raja ------------------------------------------------------------------------ Raja's Profile: http://www.thecodecage.com/forumz/member.php?userid=497 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=115089 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to use the code?
Please add code tags Code Tags -- Pecoflyer Cheers - 'Firefox 3.5' (http://www.mozilla.com/en-US/firefox/all-beta.html) really IS fast ! ------------------------------------------------------------------------ Pecoflyer's Profile: http://www.thecodecage.com/forumz/member.php?userid=14 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=115089 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to use the code?
Pecoflyer;413138 Wrote: Please add code tags Code Tags Sorry about that Pecoflyer.. I have saved the code with by clicking the code tags now. Please advice whether is that oh and help to my thread thanks. Regards, Raja -- Raja ------------------------------------------------------------------------ Raja's Profile: http://www.thecodecage.com/forumz/member.php?userid=497 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=115089 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to use the code?
In order to run any code in VB, it has to be "housed" in a Sub or Function
header at the beginning and an End Sub or End Function at the end. Your code looks like it was intended to be run as a macro, so it should have been posted this way... Sub Add99ToSerialNumber() Dim Cell As Range Dim Text As String Set Cell = Range("A1") Do Until IsEmpty(Cell) Text = Cell.Value Cell.Value = Left("990000000000", 12 - Len(Text)) & Text Set Cell = Cell.Offset(1) Loop End Sub To run this code, press Alt-F8 from the worksheet where you want to work on and pick Add99ToSerialNumber from the list that appeared and then click the Run button. -- Rick (MVP - Excel) "Raja" wrote in message ... Hi Patrick Thanks for giving me the formula to add 99 before the digit its working perfectly but i could not make use of the code which you hav esuggested, i have inserted the code by right clicking the sheet1- viewcode and pasted the code but i could not able to run the macro. So please help as im new to excel. The code is: dim cell as range dim text as string set cell = range("A1") do until isempty(cell) text = cell.value cell.value = LEFT("990000000000",12 - len(text) ) & text set cell = cell.offset(1) loop -- Raja ------------------------------------------------------------------------ Raja's Profile: http://www.thecodecage.com/forumz/member.php?userid=497 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=115089 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to use the code?
Hi Raja, I believe that Patrick assumed you would know to add the beginning
and ending lines to the macro as shown below. To run the macro, click ToolsMacroMacros, select the macro name and click "Run". Sub prfx99() '<===Macro name Dim cell As Range Dim text as String Set cell = Range("A1") Do Until IsEmpty(cell) text = cell.value cell.value = LEFT("990000000000",12 - len(text) ) & text Set cell = cell.offset(1) Loop End Sub '<===Closes macro "Raja" wrote in message ... Hi Patrick Thanks for giving me the formula to add 99 before the digit its working perfectly but i could not make use of the code which you hav esuggested, i have inserted the code by right clicking the sheet1- viewcode and pasted the code but i could not able to run the macro. So please help as im new to excel. The code is: dim cell as range dim text as string set cell = range("A1") do until isempty(cell) text = cell.value cell.value = LEFT("990000000000",12 - len(text) ) & text set cell = cell.offset(1) loop -- Raja ------------------------------------------------------------------------ Raja's Profile: http://www.thecodecage.com/forumz/member.php?userid=497 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=115089 |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to use the code?
thanks Rick and JLGWhiz
I assumed incorrectly it seems . thanks for the fix "Rick Rothstein" wrote in message ... In order to run any code in VB, it has to be "housed" in a Sub or Function header at the beginning and an End Sub or End Function at the end. Your code looks like it was intended to be run as a macro, so it should have been posted this way... Sub Add99ToSerialNumber() Dim Cell As Range Dim Text As String Set Cell = Range("A1") Do Until IsEmpty(Cell) Text = Cell.Value Cell.Value = Left("990000000000", 12 - Len(Text)) & Text Set Cell = Cell.Offset(1) Loop End Sub To run this code, press Alt-F8 from the worksheet where you want to work on and pick Add99ToSerialNumber from the list that appeared and then click the Run button. -- Rick (MVP - Excel) "Raja" wrote in message ... Hi Patrick Thanks for giving me the formula to add 99 before the digit its working perfectly but i could not make use of the code which you hav esuggested, i have inserted the code by right clicking the sheet1- viewcode and pasted the code but i could not able to run the macro. So please help as im new to excel. The code is: dim cell as range dim text as string set cell = range("A1") do until isempty(cell) text = cell.value cell.value = LEFT("990000000000",12 - len(text) ) & text set cell = cell.offset(1) loop -- Raja ------------------------------------------------------------------------ Raja's Profile: http://www.thecodecage.com/forumz/member.php?userid=497 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=115089 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
split post code (zip code) out of cell that includes full address | Excel Discussion (Misc queries) | |||
How can I modify my code to offset the defined range and repeat theprocedure instead of duplicating my code? | Excel Programming | |||
Shorten code to apply to all sheets except a few, instead of individually naming them, and later adding to code. | Excel Programming | |||
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... | Excel Programming | |||
Excel code convert to Access code - Concat & eliminate duplicates | Excel Programming |