ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Loop Problem (https://www.excelbanter.com/excel-programming/396617-loop-problem.html)

Patrick Bateman

Loop Problem
 
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


Mark Lincoln

Loop Problem
 
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


On Aug 30, 10:46 am, Patrick Bateman
wrote:
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





All times are GMT +1. The time now is 08:10 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com