tprocket
asked on
Use VBS to rearrange Excel spreadsheet
I would like to know the VBA to rearrange a spreadsheet.
This is how the spreadsheet is laid out
Part_ID 1/1/2011 1/15/2011 2/1/2011 3/15/2011 4/1/2011
ABC 2 30 2 2
X12HH 1 2 2 9 6
BNH212 2 79 80
I want to change to this
Part_ID Want_Date QTY
ABC 1/1/2011 0
ABC 1/15/2011 2
ABC 2/1/2011 30
ABC 3/15/2011 2
ABC 4/1/2011 2
X12HH 1/1/2011 1
X12HH 1/15/2011 2
X12HH 2/1/2011 2
X12HH 3/15/2011 9
X12HH 4/1/2011 6
BNH212 1/1/2011 2
BNH212 1/15/2011 0
BNH212 2/1/2011 79
BNH212 3/15/2011 80
BNH212 4/1/2011 0
Attached spreadsheet shows how I want the data to look.
Data-Example.xls
This is how the spreadsheet is laid out
Part_ID 1/1/2011 1/15/2011 2/1/2011 3/15/2011 4/1/2011
ABC 2 30 2 2
X12HH 1 2 2 9 6
BNH212 2 79 80
I want to change to this
Part_ID Want_Date QTY
ABC 1/1/2011 0
ABC 1/15/2011 2
ABC 2/1/2011 30
ABC 3/15/2011 2
ABC 4/1/2011 2
X12HH 1/1/2011 1
X12HH 1/15/2011 2
X12HH 2/1/2011 2
X12HH 3/15/2011 9
X12HH 4/1/2011 6
BNH212 1/1/2011 2
BNH212 1/15/2011 0
BNH212 2/1/2011 79
BNH212 3/15/2011 80
BNH212 4/1/2011 0
Attached spreadsheet shows how I want the data to look.
Data-Example.xls
LOL...I've even used formulas to do this, but it gets a bit complicated...using things like INDIRECT() combined with ROW() and COLUMN().
If you'd like to see that, let me know.
If you'd like to see that, let me know.
ASKER
Thanks that works out great!
I have a couple of more questions
1. What if I want to add more columns?
I modified this section to include a new column
It was
[a1:c1] = Array("Part_ID", "Want_Date", "Qty")
I changed it to
[a1:d1] = Array("Part_ID", "Desc", "Want_Date", "Qty")
but it did not add it to columns correctly, can you let me know what else I need to change
2. Also can I create a worksheet called Normalized and replace the data with the new data
I have a couple of more questions
1. What if I want to add more columns?
I modified this section to include a new column
It was
[a1:c1] = Array("Part_ID", "Want_Date", "Qty")
I changed it to
[a1:d1] = Array("Part_ID", "Desc", "Want_Date", "Qty")
but it did not add it to columns correctly, can you let me know what else I need to change
2. Also can I create a worksheet called Normalized and replace the data with the new data
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window