ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Parsing Variable Range of Data (https://www.excelbanter.com/excel-programming/291312-parsing-variable-range-data.html)

Amit

Parsing Variable Range of Data
 
I need to be able to parse data from one sheet to another. The
following would be a typical data set (this is just a sample - the
actual data set is thousands of lines long).

A B C D
5 10 15 20
3 15 10 2
5 10 15 20
3 15 10 2

I want to be able to use a macro to copy a selected range of cells
onto another sheet. For example: copy range A1:D1 from sheet #1 to
A1:D1 of sheet#2, then increment a number of rows (variable), for this
example 2. So now the macro will automatically go to A3:D3 from sheet
#1 to A2:D2 of sheet#2. I need to do this until the end of the file
(basically increment the copy/paste command by a number until the end
of file).

Thanks in Advance,

Amit

Tom Ogilvy

Parsing Variable Range of Data
 
With Worksheets("sheet1")
VariableIncr = 2
rw = 2
for i = 1 to .cells(rows.count,1).End(xlup).Row Step VariableIncr
.cells(i,1).Resize(1,4).copy destination:=Worksheets("Sheet2") _
.cells(rw,1)
rw = rw + 1
Next

You could also use a helper column to use a formula to indicate which lines
to copy, then use the autofilter to make only those rows visible, then do
the copy all at once.

--
Regards,
Tom Ogilvy

"Amit" wrote in message
om...
I need to be able to parse data from one sheet to another. The
following would be a typical data set (this is just a sample - the
actual data set is thousands of lines long).

A B C D
5 10 15 20
3 15 10 2
5 10 15 20
3 15 10 2

I want to be able to use a macro to copy a selected range of cells
onto another sheet. For example: copy range A1:D1 from sheet #1 to
A1:D1 of sheet#2, then increment a number of rows (variable), for this
example 2. So now the macro will automatically go to A3:D3 from sheet
#1 to A2:D2 of sheet#2. I need to do this until the end of the file
(basically increment the copy/paste command by a number until the end
of file).

Thanks in Advance,

Amit





All times are GMT +1. The time now is 01:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com