Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
How can I modify my code to offset the defined range and repeat theprocedure instead of duplicating my code? [email protected] Excel Programming 4 May 29th 09 10:13 PM
Shorten code to apply to all sheets except a few, instead of individually naming them, and later adding to code. Corey Excel Programming 3 December 11th 06 05:14 AM
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... Corey Excel Programming 4 November 25th 06 04:57 AM
Excel code convert to Access code - Concat & eliminate duplicates italia Excel Programming 1 September 12th 06 12:14 AM


All times are GMT +1. The time now is 11:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"