Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Your do not have matching Sub-End Subs. You have one too many Subs. Remove
the line "Sub Macro2()". "Bob" wrote in message ... Mudraker Thanks for the reply. Tried copying and pasting into (replacing) existing macro and keep getting problems This is exactly what I've pasted in Sub zeros() ' ' zeros Macro ' Macro recorded 5/26/2004 by Bob ' ' Keyboard Shortcut: Ctrl+b ' Sub Macro2() Dim Rng As Range Columns("B:B").NumberFormat = "@" For Each Rng In Range("b2:b" _ & Range("b" & Rows.Count).End(xlUp).Row) If Rng.Value < "" Then Rng.Value = "0000" & Rng.Value End If Next Rng End Sub It keeps coming back "compile error - expected end sub" Any suggestions - Thanks very much "mudraker " wrote in message ... Bob Try these for starts Both macros replace the existing number in column B with one that has 0000 at the start Macro1 runs over b2 to b100 Macro2 runs over b2 to last used cell in column B Sub Macro1() Dim Rng As Range Columns("B:B").NumberFormat = "@" For Each Rng In Range("b2:b100") If Rng.Value < "" Then Rng.Value = "0000" & Rng.Value End If Next Rng End Sub Sub Macro2() Dim Rng As Range Columns("B:B").NumberFormat = "@" For Each Rng In Range("b2:b" _ & Range("b" & Rows.Count).End(xlUp).Row) If Rng.Value < "" Then Rng.Value = "0000" & Rng.Value End If Next Rng End Sub --- Message posted from http://www.ExcelForum.com/ |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to write a macro | Excel Discussion (Misc queries) | |||
Help write Macro | Excel Discussion (Misc queries) | |||
How do i write a Macro that does following | New Users to Excel | |||
is it possible to execute write to the fields in another .xsl form a macro in another .xsl? e.g. some way to load another .xsl into an .xsl macro and write to its data? | Excel Worksheet Functions | |||
How do I write a macro for... | Excel Discussion (Misc queries) |