Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel 2000 -Simplify macro
This extract from a Macro I created in 2000 needs to be simplified as there are 12 options. Range("D8:D27").Select Selection.Replace What:="NOV", Replacement:="DEC", LookAt:= _ xlPart, SearchOrder:=xlByColumns, MatchCase:=False Range("D8:D27").Select Selection.Replace What:="OCT", Replacement:="NOV", LookAt:= _ xlPart, SearchOrder:=xlByColumns, MatchCase:=False I have also used the same approach to replace data in other situations. How can this be achieved? TIA -- ~~~~ Gerry ~~~~~~~~ Enquire, plan and execute. Stourport, England ~~~~~~~~~~~~~~~~~ |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel 2000 -Simplify macro
Monthname(13,True)
raises an error for me. Also, doing i = 1 to 12 (or 11), would change everything to DEC wouldn't it. Perhaps loop backwards, and put in some logic to handle the Dec to Jan change. -- Regards, Tom Ogilvy "John Bundy" (remove) wrote in message ... Thank you for helping me find something I didn't know but will come in handy MonthName(1, True) returns Jan so if you do a for i=1 to 12 Range("D8:D27").Select Selection.Replace What:=MonthName(i, True), Replacement:=MonthName(i+1, True), LookAt:= _ xlPart, SearchOrder:=xlByColumns, MatchCase:=False -- -John Northwest11 Please rate when your question is answered to help us and others know what is helpful. "Gerry Cornell" wrote: This extract from a Macro I created in 2000 needs to be simplified as there are 12 options. Range("D8:D27").Select Selection.Replace What:="NOV", Replacement:="DEC", LookAt:= _ xlPart, SearchOrder:=xlByColumns, MatchCase:=False Range("D8:D27").Select Selection.Replace What:="OCT", Replacement:="NOV", LookAt:= _ xlPart, SearchOrder:=xlByColumns, MatchCase:=False I have also used the same approach to replace data in other situations. How can this be achieved? TIA -- ~~~~ Gerry ~~~~~~~~ Enquire, plan and execute. Stourport, England ~~~~~~~~~~~~~~~~~ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to simplify macro | Excel Programming | |||
How do I simplify a macro in excel? | Excel Programming | |||
2nd try --Macro to transfer data in an Excel sheet (2000) in Access 2000 ( code to replace what wizard do) | Excel Programming | |||
Simplify a macro | Excel Programming | |||
Create macro to download access 2000 table to excel 2000 spreadsheet | Excel Programming |