View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bernard Liengme[_2_] Bernard Liengme[_2_] is offline
external usenet poster
 
Posts: 563
Default Loop copy/paste for x columns

Andrew, this will perform the same opeartaiuon as you subrountine
Sub TryMe()
Application.ScreenUpdating = False
mylast = Cells(Cells.Rows.Count, 23).End(xlUp).Row
For j = 1 To mylast
Cells(j, 24) = Cells(j, 23).Value
Next j
Application.ScreenUpdating = True
End Sub

We can expand on this by putting the main part within another loop
For K =23 to 60
mylast = Cells(Cells.Rows.Count, K).End(xlUp).Row
For j = 1 To mylast
Cells(j, K+1) = Cells(j, K).Value
Next j
next k

However, I am unclear what is needed. Surely you do not want to coly column
X to Y, etc
Please clarify
best wishes
--
Bernard Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme


"Andrew" wrote in message
...
Hi, I've got a macro that copies formulae in column W, pastes in column X,
then copies this and pastes values (it's probably very uncouth however).
What I'd like to to is tie this in to a loop so that it repeats along to
column CC, without having to copy in the below formulae 58 times. Any
help
would be appreciated.

Columns("W:W").Select
Selection.Copy
Columns("X:X").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False