Hello VBA scripters,
I need help on converting multiple columns into one row (actually two rows).
I have a Access table with 26 columns UnitID, Date, 1, 2, 3, 4,.......,24.
(data in column "1" means KWh used in hour 1, and samething appplies to each hour until hour 24)
I want to convert this table to four columns (rows expands to 24 times larger since columns of hours changes to rows)
UnitID, Date, Hour, KWh_used
Table before converting is below
UnitID date 1 2 3 ............ 24
777 1/1/2010 73 95 68 ............ 95
777 1/2/2010 59 87 91 ........... 102
.........
888 1/1/2010 211 222 189 ........... 235
.........
999 1/1/2010 153 133 155 ........... 143
........
and, a table structure I want to see after conversion is below
unitID Date Hour KWh
777 1/1/2010 1 73
777 1/1/2010 2 95
777 1/1/2010 3 68
........
777 1/1/2010 24 95
777 1/2/2010 1 59
777 1/2/2010 2 87
......
888 1/1/2010 1 211
888 1/1/2010 2 222
.......
Could you please help me using Visual Basic (in Access 2007) to convert multiple columns of KWh used in each hour into two columns, Hour and KWh used ?
Regards,
WUJU
I need help on converting multiple columns into one row (actually two rows).
I have a Access table with 26 columns UnitID, Date, 1, 2, 3, 4,.......,24.
(data in column "1" means KWh used in hour 1, and samething appplies to each hour until hour 24)
I want to convert this table to four columns (rows expands to 24 times larger since columns of hours changes to rows)
UnitID, Date, Hour, KWh_used
Table before converting is below
UnitID date 1 2 3 ............ 24
777 1/1/2010 73 95 68 ............ 95
777 1/2/2010 59 87 91 ........... 102
.........
888 1/1/2010 211 222 189 ........... 235
.........
999 1/1/2010 153 133 155 ........... 143
........
and, a table structure I want to see after conversion is below
unitID Date Hour KWh
777 1/1/2010 1 73
777 1/1/2010 2 95
777 1/1/2010 3 68
........
777 1/1/2010 24 95
777 1/2/2010 1 59
777 1/2/2010 2 87
......
888 1/1/2010 1 211
888 1/1/2010 2 222
.......
Could you please help me using Visual Basic (in Access 2007) to convert multiple columns of KWh used in each hour into two columns, Hour and KWh used ?
Regards,
WUJU
Last edited: