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




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
How to simplify macro Ksu Excel Programming 6 October 9th 06 08:25 PM
How do I simplify a macro in excel? Erik Excel Programming 4 November 3rd 05 02:20 PM
2nd try --Macro to transfer data in an Excel sheet (2000) in Access 2000 ( code to replace what wizard do) André Lavoie Excel Programming 0 September 27th 05 01:50 PM
Simplify a macro Einar Excel Programming 7 August 23rd 05 09:05 AM
Create macro to download access 2000 table to excel 2000 spreadsheet Tushar[_2_] Excel Programming 3 October 21st 04 02:44 PM


All times are GMT +1. The time now is 05:02 PM.

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"