vba code to copy every nth row from the data which has more than 50000 rows Head
ID: 3565003 • Letter: V
Question
vba code to copy every nth row from the data which has more than 50000 rows
Header row
B
C
D
E
F
G
H
H
I
J
K
It has to start from row 2 with entire column, copy the data and paste a new workbook and save with a name. Likewise as many files I need to create, example is below
B
C
D
Copy first 3 row items and paste it into a new workbook. Save this workbook as file 1
E
F
G
Copy next 3 row items and paste it into a new workbook. Save this workbook as file 2
H
H
I
Copy next 3 row items and paste it into a new workbook. Save this workbook as file 3
J
K
Copy balance row items(only 2 - residuary rows) and paste it into a new workbook. Save this worrkbook as file 4.
I am looking for a macro to hanndle this process automatically. Can yoou please help me onn this requirement.
Explanation / Answer
It is working fine, but I need to paste the data from row2. Row 1 should be blank. What changes do I need to make it in the code.
replace the Bold section A1 with A2
replace:
..........................
Set newWB = Workbooks.Add(xlWorksheet)
ws.Rows(x).Resize(N).Copy Range("A1")
ActiveSheet.UsedRange.EntireColumn.AutoFit
....................
with:
....................
Set newWB= = Workbooks.Add(xlWorksheeet))
ws.Rows(x).Resize(N).Copyy Range("A2") '<< this line does copy past ALL (values-formulae-formats)
ActiveSheet.UsedRange.EntireColumn.AutoFiit
.................
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.