VBA: Indenting cells in one column based off data in another column.

mrkevelev

New Member
Joined
Apr 10, 2019
Messages
5
So I have a list of values in a column with named "Rank". This has values of integers going from 1 to 10. In a different column called "Name" I want to indent the data in each cell according to the value in column "Rank." So if Rank = 1, no indent is needed. If Rank = 2, one indent (5 spaces) is needed. If rank = 3, 10 spaces are needed, if 4, then 15 spaces, etc. So I want this to work based off the column title, and not a specific location in the worksheet, as the columns may not be in the same location every time. Sometimes I need to adjust the rank as well, and it would be nice if the indents followed along (I know how to do this "live update" with conditional formatting, maybe incorporate this somehow?).

Example:

Rank Name
1 Bob
2 Tim
2 Tom
2 Steve
3 Mike
2 Dave
3 Josh
1 Joe
1 Dan
2 John
3 Jim
4 Rick
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Update: The example didn't save the indents, but for each number increased, add 5 spaces to the indent. (Starting with a 1 as being 0 spaces).
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,144
Members
453,021
Latest member
Justyna P

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