Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro Button does not work on second click


I have button1 assigned ot the following macro on the 'headerpage'
worksheet of my workbook. When the button is clicked it makes the
'Instruction' worksheet visible and active.

Sub hide_sheet()
'
Static fOn As Boolean

fOn = Not fOn
Sheets("Instructions").Visible = True = fOn
Sheets("Instructions").Select
End Sub


On the 'Instruction' worksheet I have button2 with the following code.
THis takes the user back to the 'headerpage' worksheet and rehides the
'instruction' worksheet.

Sub hide_instruction2()
'

Static fOff As Boolean
Sheets("HeaderPage").Select
fOn = Not fOn
Sheets("Instructions").Visible = False = fOn
End Sub


THE ISSUE

When youy click on button1 for the first time it works fine, then click
on button to and it indeed does take the user back to the 'headerpage'
worksheet and rehides the 'instruction' worksheet.

However, if I click on button1 again it gives me a 'runtime error 1004'
and highlights the line 'Sheets("Instructions").Select' in the Sub
hide_sheet() macro assigned to button 1.

Why? and how do I get this to work so no matter howmany times the user
wants to switch back and forth between the two pages it will allow them
to?

Thanks
Dan


--
retseort
------------------------------------------------------------------------
retseort's Profile: http://www.excelforum.com/member.php...o&userid=24690
View this thread: http://www.excelforum.com/showthread...hreadid=483613

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Macro Button does not work on second click

Hi,
Unless (and I may have!) I misunderstand what you want, the
following "flips" between the worksheets - "Headerpage" is ALWAYS visible(?)

Sub hide_sheet()
Sheets("Instructions").Visible = True
Sheets("Instructions").Select
End Sub

Sub hide_instruction2()
Sheets("HeaderPage").Select
Sheets("Instructions").Visible = False
End Sub


HTH
"retseort" wrote:


I have button1 assigned ot the following macro on the 'headerpage'
worksheet of my workbook. When the button is clicked it makes the
'Instruction' worksheet visible and active.

Sub hide_sheet()
'
Static fOn As Boolean

fOn = Not fOn
Sheets("Instructions").Visible = True = fOn
Sheets("Instructions").Select
End Sub


On the 'Instruction' worksheet I have button2 with the following code.
THis takes the user back to the 'headerpage' worksheet and rehides the
'instruction' worksheet.

Sub hide_instruction2()
'

Static fOff As Boolean
Sheets("HeaderPage").Select
fOn = Not fOn
Sheets("Instructions").Visible = False = fOn
End Sub


THE ISSUE

When youy click on button1 for the first time it works fine, then click
on button to and it indeed does take the user back to the 'headerpage'
worksheet and rehides the 'instruction' worksheet.

However, if I click on button1 again it gives me a 'runtime error 1004'
and highlights the line 'Sheets("Instructions").Select' in the Sub
hide_sheet() macro assigned to button 1.

Why? and how do I get this to work so no matter howmany times the user
wants to switch back and forth between the two pages it will allow them
to?

Thanks
Dan


--
retseort
------------------------------------------------------------------------
retseort's Profile: http://www.excelforum.com/member.php...o&userid=24690
View this thread: http://www.excelforum.com/showthread...hreadid=483613


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro Button does not work on second click


You were correct and your code offering worked great...you are truly a
GREAT ONE.

THANKS

:) :) :) :)


--
retseort
------------------------------------------------------------------------
retseort's Profile: http://www.excelforum.com/member.php...o&userid=24690
View this thread: http://www.excelforum.com/showthread...hreadid=483613

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
Macro recording won't record mouse click of add-in app button bocabuilder Excel Discussion (Misc queries) 3 March 12th 09 07:47 PM
Not able to Click Button placed in the Work Sheet Seetharaman Excel Worksheet Functions 1 January 29th 09 01:23 PM
Call Userfor and click button with macro ExcelMonkey[_190_] Excel Programming 2 February 25th 05 04:41 PM
Can't start macro via button click dan Excel Programming 1 November 3rd 04 08:48 PM
How do I set a macro to run when I click a Command Button in Exce. thewizrd Excel Programming 1 October 8th 04 06:44 PM


All times are GMT +1. The time now is 05:52 PM.

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

About Us

"It's about Microsoft Excel"