Converting horizontal list to vertical - VBA

mhaidar81

New Member
Joined
Dec 9, 2017
Messages
34
Office Version
  1. 365
Platform
  1. Windows
Hello all,

I am looking for a macro that would convert a horizontal list to a vertical one. All I can come up with is a macro to copy the row and paste it X number of times, but my list contains thousands of rows and doesn't seem very practical. Assuming ID column is column A:


A
---
ID
B
---
Project
C
---
Rate
D
---
Project A Count
E
---
Project B Count
F
---
Project C Count
G
---

Total
H
---
Rate
I
---
Project D Count
J
---
Project E Count
K
---
Project D Count
L
---

Total
100112001.01$5030540060610420

<tbody>
</tbody>

IDProjectProject NameRateCountTotal
1001Project A12001.01$503150
1001Project B12001.01$5000
1001Project C12001.01$505250
1001Project DFR0006$606360
1001Project EFR0003$60160
1001Project FFR0005$6000

<tbody>
</tbody>

After the list is converted:


  • Project A, Project B, and Project C should always populate “Project Name” with the value from Column B
  • Project D should populate “Project Name” with the value “FR0006”
  • Project E should populate “Project Name” with the value “FR0003”
  • Project F should populate “Project Name” with the value “FR0005”

I would appreciate any help with this
 
Hey guys, I have a follow-up question on this. Let's say that there are additional columns within my sheet that contain useless information and I have no interest in converting them into the vertical format. Can I select the columns that I'm only interested in? The number of columns will be fixed in the sheet.
 
Upvote 0

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Never mind, I figured it out!

Hey guys, I have a follow-up question on this. Let's say that there are additional columns within my sheet that contain useless information and I have no interest in converting them into the vertical format. Can I select the columns that I'm only interested in? The number of columns will be fixed in the sheet.
 
Upvote 0
You can do that in my code by changing the below

Rich (BB code):
Set Rg = ActiveSheet.Range("A1").CurrentRegion '<--- Comment/delete this line

Set Rg = ActiveSheet.Range("A1", Range("L" & Rows.Count).End(xlUp))  '<--- Replace with this line

 
Upvote 0

Forum statistics

Threads
1,216,524
Messages
6,131,176
Members
449,629
Latest member
Mjereza

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top