simplify a macro

S

Shooter

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.
 
V

vezerid

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
 
D

Dana DeLouis

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top