Imbetteratjava
New Member
- Joined
- Jan 6, 2022
- Messages
- 3
- Office Version
-
- 365
- Platform
-
- Windows
Hi,
New to some of the VB terminology in excel and I can't seem to get this to work.
I've taken some examples on this site and put them together with others but I'm coming up short on a solid solution.
I have data in a range of B2:G2 down to blank rows (undefined)
I want to copy the first row of data (B2:G2) and paste it in another sheet starting at point (A2) then + ~about 10 to 20 spaces to give me room for a large picture
Then copy the next set eg (B3:G3)
Here's what I've been messing around with so far.
Any tips or help appreciated.
Thanks.
New to some of the VB terminology in excel and I can't seem to get this to work.
I've taken some examples on this site and put them together with others but I'm coming up short on a solid solution.
I have data in a range of B2:G2 down to blank rows (undefined)
I want to copy the first row of data (B2:G2) and paste it in another sheet starting at point (A2) then + ~about 10 to 20 spaces to give me room for a large picture
Then copy the next set eg (B3:G3)
Here's what I've been messing around with so far.
VBA Code:
Sub NewMacro()
Dim ws1, ws2 As Worksheet
Dim copyRng, cell As Range
Dim lCopyLastRow As Long
Set ws1 = ThisWorkbook.Sheets(1)
Set ws2 = ThisWorkbook.Sheets(2)
'Find last used row in the copy range based on data in column A
lCopyLastRow = ws1.Cells(ws1.Rows.Count, "A").End(xlUp).Row
Set copyRng = ws1.Range("B2:G" & lCopyLastRow).End(x1Down).Row 'Getting an application-defined or object-defined error
For Each cell In copyRng
ws2.Range("A" & 2 + 10 * copyRng.Rows(cell.Row).Row - 30).Value = cell.Value
Next cell
End Sub
Any tips or help appreciated.
Thanks.