Loop Problem

P

Patrick Bateman

I am using a loop to try and copy information in a vertical range to be
displayed in a horizontal range as the next values at the bottom of a list

so far i have:

Private Sub Insert_Click()

Dim x, y
x = 4
Do Until y = 45

If Sheets("sheet2").Cells(x, 45) = "" Then

Range(Cells(10, 6), Cells(19, 6)).Copy _
Destination:=Range(Sheets("sheet2").Cells(x, 45),
Sheets("sheet2").Cells(x, 54))

y = 45

End If
x = x + 1

Loop
End Sub


but this just copies the vertical range of values multiple times across the
specified copy range, not transposing it as i would like it to do.

any suggestions would be much appreciated

regards Patrick
 
M

Mark Lincoln

Patrick,

Try this (not tested):


Private Sub Insert_Click()

Dim x, y
x = 4
Do Until y = 45

If Sheets("sheet2").Cells(x, 45) = "" Then

Range(Cells(10, 6), Cells(19, 6)).Copy
Range(Sheets("sheet2").Cells(x, 45).PasteSpecial
Transpose:=True

y = 45

End If
x = x + 1

Loop
End Sub

Mark Lincoln
 

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