View Full Version : Reorienting Data


ckrider
01-19-2011, 11:53 AM
I'm new to VB and need to process some data to accommodate a template for data upload. The orientation of the results needs to be places all in one column, they are currently in multiple columns by analyte. Reorienting the results is the easy part.

The part I'm stuck on is coping and pasting each sampling location 15 times to track the new orientation.

So, each sampling location needs to be repeated 15 times, it is currently noted once. How do I insert 14 blank cells between each record and copy down the contents?

Thanks!!:D

example attached

Brianwarnock
01-19-2011, 12:05 PM
Are you saying that what is currently in Row2 should appear in rows 2 -16 and Row 3 in 17 - 31 etc

Brian

ckrider
01-19-2011, 12:11 PM
Yes. But the real dataset is over 400 records long...so a VB script would be better than doing it manually.

Brianwarnock
01-20-2011, 05:39 AM
Obviously, just seeking clarification.

Brian

Brianwarnock
01-20-2011, 06:43 AM
This should do it for you

Brian

Sub copysub()

'Brian Jan 2011
'copy each row on sheet1 15 times into sheet2

Dim sheet1row As Integer
Dim sheet2row As Integer
Dim counter As Long

'Copy Heading Row
Sheets("sheet1").Rows(1).copy Destination:=Sheets("Sheet2").Cells(1.1)

sheet2row = 2
For sheet1row = 2 To Sheets("sheet1").Cells(65536, 1).End(xlUp).Row
For counter = 1 To 15
Sheets("sheet1").Rows(sheet1row).copy Destination:=Sheets("Sheet2").Cells(sheet2row, 1)
sheet2row = sheet2row + 1
Next counter
Next sheet1row
End Sub

ckrider
01-20-2011, 03:16 PM
Thanks! I actually figured it out by using a less sophisticated method...by creating a tag column and numbering the entire dataset 1 - n and then copy and pasting it 15 times then sorting. Kinda lame...but got it done...

Thanks for the help...looking forward to learning more about VB;)

Brianwarnock
01-21-2011, 05:37 AM
Getting the job done is the number 1 priority, learning how to do it better can come after.

Brian