Make a Macro only run on unhidden columns

danielstone121

New Member
Joined
Feb 14, 2013
Messages
45
Hey guys-

I want to be able to hide and show every other column on a sheet (B, D, F, H, J, L, N, P, R, T, V, X, ect.) but only within the range that I am currently viewing. In other words, let's say I click the "Show" macro that will show every other column, from A to the end of the sheet. But I only want to see the columns from the "every other" macro that are ALSO within the current viewing window. Meaning, I only would want to see columns B, D, F, H, J, L, N, and P, since those are the columns that meet the "every other" criteria AND fall within the current, visible window.

ABCGHIMNOP

<tbody>
</tbody>


I apologize if I'm being confusing. I guess I am wondering if I can restrict a macro that is set to run on the entire sheet to only actually run on a specific range. Or, perhaps another way of asking. Let's say I have two control boxes: one for "Hide every other column" and one for "Show all columns". Is there a way to make it so that if the "Hide every other column" box is clicked, all other macros will run the "Hide every other column" first?
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Forum statistics

Threads
1,216,739
Messages
6,132,442
Members
449,728
Latest member
teodora bocarski

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