Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Using Command Button to Hide Columns in another worksheet

Hello All,

I created what I thought was a really simple workbook, but have run
across a macro error that I can't seem to solve. Probably really simple
for some, but has stumped me on working any further on the workbook:

I recorded a macro to hide a column on a specific worksheet (code
below):

Sheets("Sheet1").Select
Columns("H:H").Select
Selection.EntireColumn.Hidden = True

However, when I copied the code to a command button on another
worksheet I get:

"Run-time error '1004':

Select method of Range class failed"

The macro works fine when I run it through the menu, however it will
not work with the command button. When I click on the Debug, it
highlights the "Columns("H:H").Select"

Any insight will be appreciated...

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Using Command Button to Hide Columns in another worksheet

You could change your code to...
Sheets("Sheet1").Columns("H:H").EntireColumn.Hidde n = True
(no selection is done)
-or-
If you are using buttons from the Control Toolbox try ...
Changing the TakeFocusOnClick property of the button to False.

Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"AndrewJ"

wrote in message
Hello All,
I created what I thought was a really simple workbook, but have run
across a macro error that I can't seem to solve. Probably really simple
for some, but has stumped me on working any further on the workbook:
I recorded a macro to hide a column on a specific worksheet (code
below):

Sheets("Sheet1").Select
Columns("H:H").Select
Selection.EntireColumn.Hidden = True

However, when I copied the code to a command button on another
worksheet I get:

"Run-time error '1004':

Select method of Range class failed"

The macro works fine when I run it through the menu, however it will
not work with the command button. When I click on the Debug, it
highlights the "Columns("H:H").Select"
Any insight will be appreciated...
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Using Command Button to Hide Columns in another worksheet

Thanks alot Jim,

I previously tried chaning the TakeFocusOnClick property before
posting, but with no luck, but changing my code so that no selecting is
required worked perfectly. Thanks again.

Jim Cone wrote:
You could change your code to...
Sheets("Sheet1").Columns("H:H").EntireColumn.Hidde n = True
(no selection is done)
-or-
If you are using buttons from the Control Toolbox try ...
Changing the TakeFocusOnClick property of the button to False.

Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"AndrewJ"

wrote in message
Hello All,
I created what I thought was a really simple workbook, but have run
across a macro error that I can't seem to solve. Probably really simple
for some, but has stumped me on working any further on the workbook:
I recorded a macro to hide a column on a specific worksheet (code
below):

Sheets("Sheet1").Select
Columns("H:H").Select
Selection.EntireColumn.Hidden = True

However, when I copied the code to a command button on another
worksheet I get:

"Run-time error '1004':

Select method of Range class failed"

The macro works fine when I run it through the menu, however it will
not work with the command button. When I click on the Debug, it
highlights the "Columns("H:H").Select"
Any insight will be appreciated...


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Command Button to show/hide a different worksheet Marilyn Excel Discussion (Misc queries) 1 April 22nd 09 03:37 AM
Hide command button MarcoR Excel Programming 2 May 12th 06 05:31 PM
Command Button to Hide/Unhide Rows Bea Excel Discussion (Misc queries) 4 March 16th 06 03:21 PM
how do you hide a forms command button Paul James[_3_] Excel Programming 4 September 5th 03 06:18 PM
Hide command button on worksheet Mohair Excel Programming 3 July 14th 03 11:06 PM


All times are GMT +1. The time now is 10:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"