macro code shortcut

B

Brian

I am using the following code in a macro and the purpose is to have cells in
a column take on the value of the cells in the column beside it...

Private sub
range ("i7:i600").value=Range("h7:h600").value
range ("h7:h600").value=Range("g7:g600").value
range ("g7:g600").value=Range("f7:f600").value
end sub

I want to expand the above macro to do approximately 100 additional columns.
Do I have to write out each line individually or is there a shorter code that
will do this.

Thanks.
 
D

Don Guillett

if col g becomes the values of col f, how does now col h become the value
for col g??
 
B

Brian

The code described below will do this. I am just wondering if there is a
better(shorter) way to write the code to do many more columns. There may not
be a shorter way to write this.
 
D

Don Guillett

Perhaps you should read my reply again and start over with a more complete
explanation. I'm getting kind of old and don't hear well.
 
A

Art

Try this:

Sub test()
Dim i As Integer
For i = 9 To 7 Step -1
Range(Cells(1, i), Cells(600, i)).Value = _
Range(Cells(1, i - 1), Cells(600, i - 1)).Value
Next i
End Sub

Art
 

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