LukiiMaxim96
New Member
- Joined
- May 18, 2021
- Messages
- 9
- Office Version
- 365
- Platform
- Windows
Hi! I got it almost working but I am stuck with the loop at the end of the code unfortunately.
I need to go through the rows of a worksheet one by one and copy the content to the last x rows of another column.
It works but I do not know how to tell the loop to go to the next row and copy that with each cycle until end is reached.
This is my code:
Any help is appreciated!
I need to go through the rows of a worksheet one by one and copy the content to the last x rows of another column.
It works but I do not know how to tell the loop to go to the next row and copy that with each cycle until end is reached.
This is my code:
VBA Code:
Sub Test1()
Dim x As Integer
Dim lRow4C As Long
Dim lRow5F As Long
'count rows
lRow4C = Tabelle4.Range("C" & Rows.Count).End(xlUp).Row
nRows = Tabelle4.Range("C10", "C" & lRow4C).Rows.Count
Set CountaColumnsRange = Tabelle4.Range("K10:AH10")
CountaColumnsResult = WorksheetFunction.CountA(CountaColumnsRange)
'copy paste start
lRow5F = Tabelle5.Range("F" & Rows.Count).End(xlUp).Row
Tabelle4.Range("C10").Copy
Tabelle5.Range("F" & lRow5F + 1, "F" & lRow5F + CountaColumnsResult).PasteSpecial xlPasteValues
Tabelle4.Range("C10").Select
'CopyPaste times rows counted loop
For x = 1 To nRows - 1
lRow5F = Tabelle5.Range("F" & Rows.Count).End(xlUp).Row
ActiveCell.Offset(1, 0).Copy
Tabelle5.Range("F" & lRow5F + 1, "F" & lRow5F + CountaColumnsResult).PasteSpecial xlPasteValues
Next
End Sub
Any help is appreciated!