Hiding columns using VBA

marcus.brown

Board Regular
Joined
Jun 23, 2008
Messages
61
Hi,

I am trying to hide columns using a macro, but it doesn't seem to be working properly.

The code I'm using is as follows.

Columns("JLT:MFS").Select
Range("JLT2").Activate
Selection.EntireColumn.Hidden = True

I'm not sure how relevant it is, but some cells are merged - JLT1:MOM1 is merged to 1 cell. When I run the code, the macro hides all the columns from JLT to MOM (inclusive).

I have more columns like the above which need to be hidden, and I encounter the same problem.

Please can you help.

Thanks
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
try this:

Columns("JLT:MFS").Select
Selection.EntireColumn.Hidden = True

Just to add to that. You will have to unmerge the columns first unfortunately
 
Last edited:
Upvote 0
unmerge?!?? *@&*%$!!!! Sorry, but that just isn't a feasible option - it's tabulated data and by unmerging the cells, it becomes impossible to read - due to the sheer size of it.

Is there no way around it (other than manually doing this, which would take about 10+ hours, due to how slow the machine is running).
 
Upvote 0

Forum statistics

Threads
1,224,548
Messages
6,179,451
Members
452,915
Latest member
hannnahheileen

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