Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Deactivate button macro if condition not met

Hi,

This is probably simple, but I am getting stuck with it.

I have a button with an attached macro. Cell A1 sets the permission that
allows the macro to run or not run as follows:

If Cell A1 is 1 the macro may continue to run.
If Cell A1 is 0 the macro may not run further and a popup alert should say,
"Stop! Button may not be used on this page."

I don't want to use data validation's conditional alert, because it would
cause a popup when the page opens and not when the user selects the button
mentioned above.

I'm trying If, Then, End if statements, but keep getting error messages.

Thank you for helping.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200912/1

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default Deactivate button macro if condition not met

Hi

How about something like this;

If Range("A1").Value = 1 Then
'Run your code
Else
MsgBox "Stop! Button may not be used on this page."

Exit Sub

End Sub

Take care

Marcus
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Deactivate button macro if condition not met

Thank you.

Will try it out.

Appreciate the help.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200912/1

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Deactivate button macro if condition not met

Thank you Marcus,

I had to add in an End if, and it works.

If Range("A1").Value = "" Then
'Run your code

Else: MsgBox "Stop! Button may not be used on this page."

Exit Sub
End If

End Sub

--
Message posted via http://www.officekb.com

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
activate/deactivate the scroll button by vba MicrosoftNews Excel Programming 3 December 1st 07 10:24 PM
Deactivating a Forms macro button based on a worksheet condition? Ace70 Excel Discussion (Misc queries) 3 June 10th 07 10:31 PM
deactivate macro or LostFocus Harold Good Excel Programming 8 January 17th 06 06:01 PM
activate/deactivate button with macro at given condition arcq Excel Programming 1 March 17th 05 05:35 AM
Remove Userform Deactivate Button Martin Excel Programming 1 September 27th 04 03:20 PM


All times are GMT +1. The time now is 06:48 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"