View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default 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
~~~~~~~~~~~~~~~~~