![]() |
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 |
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 |
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 |
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 |
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 |
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 |
All times are GMT +1. The time now is 07:21 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com