Im trying to make a macro that will reorganize data from a a comma delimited text file. Ive set up the macro to import the file into excel.
Then I get a worksheet with many similarly shaped blocks of data. Ive set up the macro to grab the data I want out of the top block and place it in a second worksheet. But then comes the problem. I dont quite understand how to loop this macro to move down the page and grab data.
I have many block with a shape similar to this:
x
x
y1
x
x
a1 b1 c1
d1 e1 f1
g1 h1 i1
There are many more blocks like this. They all have one y value and 21 rows of abc values. Each block is separated by 1 empty row.
Im trying to get the data into this format:
y1 a1 b1 c1
y1 d1 e1 f1
y1 g1 h1 i1
y2 a2 b2 c2
y2 d2 e2 f2
y2 g2 h2 i2
.
.
.
Here is the copy/paste portion for the first block. Im not sure how to make this a loop.
Sheets("Text File"
.Select
ActiveSheet.Range("A4"
.Select
Selection.Copy
Sheets("Results"
.Select
ActiveSheet.Range("A1:A21"
.Select
ActiveSheet.Paste
Sheets("Text File"
.Select
Range("A18:H38"
.Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Results"
.Select
Range("B1"
.Select
ActiveSheet.Paste
Thanks for any advice.
Ed.
Then I get a worksheet with many similarly shaped blocks of data. Ive set up the macro to grab the data I want out of the top block and place it in a second worksheet. But then comes the problem. I dont quite understand how to loop this macro to move down the page and grab data.
I have many block with a shape similar to this:
x
x
y1
x
x
a1 b1 c1
d1 e1 f1
g1 h1 i1
There are many more blocks like this. They all have one y value and 21 rows of abc values. Each block is separated by 1 empty row.
Im trying to get the data into this format:
y1 a1 b1 c1
y1 d1 e1 f1
y1 g1 h1 i1
y2 a2 b2 c2
y2 d2 e2 f2
y2 g2 h2 i2
.
.
.
Here is the copy/paste portion for the first block. Im not sure how to make this a loop.
Sheets("Text File"
ActiveSheet.Range("A4"
Selection.Copy
Sheets("Results"
ActiveSheet.Range("A1:A21"
ActiveSheet.Paste
Sheets("Text File"
Range("A18:H38"
Application.CutCopyMode = False
Selection.Copy
Sheets("Results"
Range("B1"
ActiveSheet.Paste
Thanks for any advice.
Ed.