#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11
Default simplify a macro

My macro contains the following code:

Range ("I7:I1600).Value=Range ("H7:H1600).value
Range ("H7:H1600).Value=Range ("G7:G1600).value
Range ("G7:G1600).Value=Range ("F7:F1600).value
Range ("F7:F1600).Value=Range ("E7:E1600).value
End Sub

The above 4 lines of the macro is only a small portion of the entire macro.
The entire macro covers approximately 200 columns(F:GW) and thus the macro
needs to be 200 rows long.
Due to the consistency of the code, is there a way to substantially condence
the code to achieve the same result? Thanks for your help.
--
Shooter
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 751
Default simplify a macro

Shooter,

is there a reason you cannot simply select cells F7:FW7 and issue
Insert|Cells...Shift cells down?

A VBA code for this is:

Sub insF7_GW7()
Application.DisplayAlerts = False
Range("f7:GW7").Insert xlShiftDown
Application.DisplayAlerts = True
End Sub

HTH
Kostis Vezerides

On Jan 31, 8:37 pm, Shooter wrote:
My macro contains the following code:

Range ("I7:I1600).Value=Range ("H7:H1600).value
Range ("H7:H1600).Value=Range ("G7:G1600).value
Range ("G7:G1600).Value=Range ("F7:F1600).value
Range ("F7:F1600).Value=Range ("E7:E1600).value
End Sub

The above 4 lines of the macro is only a small portion of the entire macro.
The entire macro covers approximately 200 columns(F:GW) and thus the macro
needs to be 200 rows long.
Due to the consistency of the code, is there a way to substantially condence
the code to achieve the same result? Thanks for your help.
--
Shooter



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 947
Default simplify a macro

Maybe one option:

Sub Demo()
Dim C As Long

With Range("F7:GW1600")
For C = .Columns.Count To 2 Step -1
.Columns(C).Value = .Columns(C - 1).Value
Next C
End With
End Sub

--
HTH :)
Dana DeLouis
Windows XP & Office 2003


"Shooter" wrote in message
...
My macro contains the following code:

Range ("I7:I1600).Value=Range ("H7:H1600).value
Range ("H7:H1600).Value=Range ("G7:G1600).value
Range ("G7:G1600).Value=Range ("F7:F1600).value
Range ("F7:F1600).Value=Range ("E7:E1600).value
End Sub

The above 4 lines of the macro is only a small portion of the entire
macro.
The entire macro covers approximately 200 columns(F:GW) and thus the macro
needs to be 200 rows long.
Due to the consistency of the code, is there a way to substantially
condence
the code to achieve the same result? Thanks for your help.
--
Shooter



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,081
Default simplify a macro

Why not use

range("F7:GW1600").Value=Range ("E7:GV1600").value


"Shooter" wrote:

My macro contains the following code:

Range ("I7:I1600).Value=Range ("H7:H1600).value
Range ("H7:H1600).Value=Range ("G7:G1600).value
Range ("G7:G1600).Value=Range ("F7:F1600).value
Range ("F7:F1600).Value=Range ("E7:E1600).value
End Sub

The above 4 lines of the macro is only a small portion of the entire macro.
The entire macro covers approximately 200 columns(F:GW) and thus the macro
needs to be 200 rows long.
Due to the consistency of the code, is there a way to substantially condence
the code to achieve the same result? Thanks for your help.
--
Shooter

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 do I email amacro? leo Excel Worksheet Functions 24 August 9th 06 02:47 PM
error when running cut & paste macro Otto Moehrbach Excel Worksheet Functions 4 August 9th 06 01:49 PM
Search, Copy, Paste Macro in Excel [email protected] Excel Worksheet Functions 0 January 3rd 06 06:51 PM
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM
Highlight Range - wrong macro, please edit. Danny Excel Worksheet Functions 8 October 19th 05 11:11 PM


All times are GMT +1. The time now is 04:38 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"