Hi
I got it right to copy the same data to certain amount of rows specified in column G but can't seem to get it to copy to the next open row on sheet2 it keeps copying over the same data.
It work before with End(xlUp).Row + 1 but not now.
Sub CountRows()
Dim lastRow As Long
Dim startCell As Range
Dim i As Long
Dim rowCount As Long
' Set the starting cell
Set startCell = Sheets("Sheet1").Range("G1")
' Find the last row in column G
lastRow = Sheets("Sheet1").Cells(Rows.Count, "G").End(xlUp).Row
' Calculate the row count
rowCount = lastRow - startCell.Row + 1
' Display the result
MsgBox "Number of rows: " & rowCount
' Copy the range "A1:A6"
Sheets("Sheet1").Range("A1:A6").Copy
' Start looping through the rows
For i = 1 To rowCount
' Paste the value in each row of a specific column (e.g., column A)
Sheets("Sheet2").Range("A" & i).PasteSpecial Transpose:=True
Next i
Application.CutCopyMode = False ' Clear the clipboard
End Sub
I got it right to copy the same data to certain amount of rows specified in column G but can't seem to get it to copy to the next open row on sheet2 it keeps copying over the same data.
It work before with End(xlUp).Row + 1 but not now.
Sub CountRows()
Dim lastRow As Long
Dim startCell As Range
Dim i As Long
Dim rowCount As Long
' Set the starting cell
Set startCell = Sheets("Sheet1").Range("G1")
' Find the last row in column G
lastRow = Sheets("Sheet1").Cells(Rows.Count, "G").End(xlUp).Row
' Calculate the row count
rowCount = lastRow - startCell.Row + 1
' Display the result
MsgBox "Number of rows: " & rowCount
' Copy the range "A1:A6"
Sheets("Sheet1").Range("A1:A6").Copy
' Start looping through the rows
For i = 1 To rowCount
' Paste the value in each row of a specific column (e.g., column A)
Sheets("Sheet2").Range("A" & i).PasteSpecial Transpose:=True
Next i
Application.CutCopyMode = False ' Clear the clipboard
End Sub