Need to expand columns based on a value

AkhilAnilkumar

New Member
Joined
Jan 31, 2022
Messages
3
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hey guys,

I need help in expanding columns based on the value in one column.
1643678440856.png


So this is my sheet. Based on the value in column B, columns C-G must show up. For example, if value in column B is 2, column C-G must show up two times (in the same order) and so on.
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Hello,

Can you elaborate a little more?

*It is not the column width that you want to change.
* You are not inserting any new columns.

What would happen if B1 value was 3? Would Columns, C, D & E all show "Bay angle? (And Type of Violation' would disappear??

Jamie
 
Upvote 0
Hello,

Can you elaborate a little more?

*It is not the column width that you want to change.
* You are not inserting any new columns.

What would happen if B1 value was 3? Would Columns, C, D & E all show "Bay angle? (And Type of Violation' would disappear??

Jamie
So columns C-G must multiply depending on the value in column B. I have pasted an example of column B having a value 2 and how I need to excel sheet to be.
1643688215966.png


If column B is 1, then
1643688261539.png


Does this clear the question?
 
Upvote 0
I used row 9 not row 100.

In cell H1 type =IF(H9>$B$2,"",C1) - make sure B2 has $s to hold the position. (Copy as far as you want)

In cell H9 type the number 2

In cell I9 type =H9 (Copy I9 to J9, k9, L9)

Select H9 to L9 (Copy as far as you want) NB It 'should make M9 to a number 3 - if not change every 5th cell to 3, 4, 5, ...

Went finished and it is OK. you can select all the cells in row 9 and move them to row 100, or anywhere else.

Hope that all works for you. :)

Jamie
 
Upvote 0
I used row 9 not row 100.

In cell H1 type =IF(H9>$B$2,"",C1) - make sure B2 has $s to hold the position. (Copy as far as you want)

In cell H9 type the number 2

In cell I9 type =H9 (Copy I9 to J9, k9, L9)

Select H9 to L9 (Copy as far as you want) NB It 'should make M9 to a number 3 - if not change every 5th cell to 3, 4, 5, ...

Went finished and it is OK. you can select all the cells in row 9 and move them to row 100, or anywhere else.

Hope that all works for you. :)

Jamie
I am not able to view the attachment and I am finding it difficult to understand what's happening
 
Upvote 0
You could do it without a helper row like this.
  • Put the 5 headings in C1:G1
  • Select C1:G1 and drag right as far as you might ever need headings (I have just done 4 lots in the first mini-sheet below)
  • Select from C1 to the end of all those repeated headings (V1 in my example)
  • Home ribbon tab -> Conditional Formatting -> New rule ... -> Use a formula to determine which cells to format -> Format values where this formula is true:- =COUNTIF($C1:C1,C1)>$B2 -> Format... -> Font tab -> Choose white in the 'Color:' drop-down -> OK -> OK


22 02 01.xlsm
BCDEFGHIJKLMNOPQRSTUVW
1NumberBay lengthBay angleTypeRequiredActualBay lengthBay angleTypeRequiredActualBay lengthBay angleTypeRequiredActualBay lengthBay angleTypeRequiredActual
Repeat headings


So, with a 4 in B2 you now see this

22 02 01.xlsm
BCDEFGHIJKLMNOPQRSTUVW
1NumberBay lengthBay angleTypeRequiredActualBay lengthBay angleTypeRequiredActualBay lengthBay angleTypeRequiredActualBay lengthBay angleTypeRequiredActual
24
Repeat headings
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C1:V1Expression=COUNTIF($C1:C1,C1)>$B2textNO


If we change B2 to 2:

22 02 01.xlsm
BCDEFGHIJKLMNOPQRSTUV
1NumberBay lengthBay angleTypeRequiredActualBay lengthBay angleTypeRequiredActualBay lengthBay angleTypeRequiredActualBay lengthBay angleTypeRequiredActual
22
Repeat headings
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C1:V1Expression=COUNTIF($C1:C1,C1)>$B2textNO
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,964
Members
452,371
Latest member
Frana

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