How to copy data after at a fixed cell
Solved/Closed
skprma
Posts
1
Registration date
Tuesday 29 March 2022
Status
Member
Last seen
29 March 2022
-
Updated on Mar 29, 2022 at 06:56 AM
skprma - 13 Apr 2022 à 11:47
skprma - 13 Apr 2022 à 11:47
Related:
- How to copy data after at a fixed cell
- How to copy data from one excel sheet to another - Guide
- Tmobile data check - Guide
- How to reinstall windows 10 without losing data - Guide
- How to copy data to multiple worksheets in Excel - Guide
- Data transmission cables - Guide
1 response
TrowaD
Posts
2921
Registration date
Sunday 12 September 2010
Status
Contributor
Last seen
27 December 2022
555
12 Apr 2022 à 12:12
12 Apr 2022 à 12:12
Hi Skprma,
I noticed that each entry start with a number that increases with each entry. When this number is a single value in column A (to determine the beginning and the end of an entry) AND column A doesn't contain empty cells (to determine the last row used), then you can give the code below a try:
Note that in the code, the source sheet is called 'Sheet1' and the destination sheet is called 'Sheet2'.
Best regards,
Trowa
I noticed that each entry start with a number that increases with each entry. When this number is a single value in column A (to determine the beginning and the end of an entry) AND column A doesn't contain empty cells (to determine the last row used), then you can give the code below a try:
Sub RunMe()
Dim lRow, fcRow, lcRow, x, y As Long
Sheets("Sheet1").Select
lRow = Range("A1").End(xlDown).Row
x = 2
y = 2
fcRow = 2
For Each cell In Range("A2:A" & lRow)
If cell.Value = x Then
lcRow = cell.Row - 1
Rows(fcRow & ":" & lcRow).Copy Sheets("Sheet2").Rows(y)
fcRow = cell.Row
x = x + 1
y = y + 8
End If
Next cell
Rows(fcRow & ":" & lRow).Copy Sheets("Sheet2").Rows(y)
End Sub
Note that in the code, the source sheet is called 'Sheet1' and the destination sheet is called 'Sheet2'.
Best regards,
Trowa
13 Apr 2022 à 11:47
This worked perfectly, thanks a ton!