macro problem when i hide fields how to get around?

ap1

New Member
Joined
Mar 11, 2002
Messages
26
Hi,
I am trying to hide 2 columns when i hide it without macro it only selects the 2 columns which i selected but when i run it with macro it selects all the columns and hides everything.
It must be doing it because i have merge fields at the top of the sheet. but why does it not do that outside of macro?
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hi ap1,

This is just one of many examples of recorded code that does not do the same thing as the manual operations that were recorded. Recording is a handy feature, but occasionally one must actually write the VBA code manually to get it to do what you want. Usually the result of writing the code manually is also much cleaner, more efficient code, as is the case in this instance. You should be able to change your code to (this example just for hiding column D):

Columns(4).Hidden = True
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,279
Members
449,075
Latest member
staticfluids

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