A little nuisance I'd like to do away with. Can you help?

L

Legacy 98055

Guest
Hey everyone!
I appreciate the great help in here!

Here's an example of something I have put up with for a long time, but perhaps someone in here has dealt with the same problem.

There are several examples but I'll give you the one I use the most.

I have a Hide and Unhide macros which do the obvious for column headers, sheet tabs, ect, ect...

Why does it seem neccesary that there has to be an active cell before this macros will run with no errors?

If I run this Macro and several others have had the same problem, I recieve a Method of Range type error. It's not usually a huge deal, but sometimes I have not wanted to select any cell for one reason or another.
When I do activate a cell with, activate or select, the macro runs fine...?

This seems to be a problem whenever dealing with Excel objects. No other macros are dependant on this active cell thingamabob.

I appreciate you reading my book and posting a reply.

Tom
This message was edited by TsTom on 2002-03-26 05:41
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
I recognize the problem. Some VBA methods expect a cell to be selected in order to work. This is the case for the CurrentRegion method, and probably for a couple of other ones too. The problem occurs when a macro is activated by a command button. The button gets the focus when it is pressed, which deselects the active cell. I usually solve this problem by selecting a cell (e.g. "A1") in the CurrentSheet at the start of the macro.

Marc
 
Upvote 0
Hi Tom

Marc has hit the nail on the head! If the CommandButton is from the Contol toolbox you can set It's TakeFocusOnClick Property to False as another fix.
 
Upvote 0
Thanks guys
Am going to test it immediately.
Take focus on click = Not
Got It
Tom
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,693
Members
448,979
Latest member
DET4492

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