Code to switch views of columns

ExcelRoy

Well-known Member
Joined
Oct 2, 2006
Messages
2,540
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I ma trying to generate a macro that when run will offer me certain columns to view and hide unnecessary columns

I have run the following using the macro recorder but this doesn't seem to worknymore
Code:
Sub View_Meeting()

    Columns("A:E").Select
    Selection.EntireColumn.Hidden = False
    Columns("F:FS").Select
    Selection.EntireColumn.Hidden = True
    Range("A1").Select
    
End Sub
This was working before I made some changes to the workbook but none of the changes are code changes

Would there a be a more robust option available, or a better written code option maybe?

many thanks
 
Last edited:

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Do you have any merged cells?
 
Upvote 0
Hi Fluff,

yes, I do!
Is there a way to include this into new code?

Thanks
 
Upvote 0
Try
Code:
Sub View_Meeting()
    Columns("A:E").Hidden = False
    Columns("F:FS").Hidden = True
    Range("A1").Select
End Sub
but it's best to avoid merged cells like the plague. They'll only comeback to haunt you.
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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