Auto hide altnerative columns

nethergate

New Member
Joined
Jun 29, 2014
Messages
21
Hi Guys,

I have a file in a specific format from another department. I wish to see only column D and G for "Cost" and I have 36 columns of these. Is there any quick way to hide all Columns with the name Mix & price?

B
C
D
E
F
G
Mix
Price
Cost
Mix
Price
Cost

<tbody>
</tbody>

I do know a little bit of excel VBA
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Assuming your headers in Row 1 then try below code..

Code:
Sub HideColumns()


Dim rng As Range
For Each rng In Range("[COLOR=#0000cd]A1[/COLOR]:" & Range("[COLOR=#0000cd]XFD1[/COLOR]").End(xlToLeft).Address)
        If UCase(Trim(rng.Value)) = "MIX" Or UCase(Trim(rng.Value)) = "PRICE" Then
                rng.EntireColumn.Hidden = True
        End If
Next rng
End Sub
 
Upvote 0
Thanks. What if I have another worksheet and I wish to show only the first month of each quarter i.e. hide column D/E and hide column G/H. Is there another way to write the code?

Row/Column
C
D
EFG
1
Jan
Feb
Mar
Apr
May

<tbody>
</tbody>
 
Upvote 0

Forum statistics

Threads
1,213,507
Messages
6,114,029
Members
448,543
Latest member
MartinLarkin

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