V
VexedFist
I am trying to setup my Worksheet to only Enable buttons when there is
a date present in cell B2. The script I have below works, but has some
issues. Message box comes up twice, etc..
This is part of a Large Workbook with many macros the users steps thru.
I wanted to only enable the button in the proper order. Example:
A date must be in cell B2 to enable Button-1.
Once Button-1 is pushed Button-2 is enabled and Button-1 is Disabled.
any ideas or suggestions would be appreciated.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Msg, Style, Title, Response
Sheets("Study Dates").Select
Range("B2").Select
Selection.NumberFormat = "d-mmm-yy"
If IsEmpty(ActiveCell) = True Then
Day1Button.Enabled = False
Day2Button.Enabled = False
Day3Button.Enabled = False
Day4Button.Enabled = False
Day5Button.Enabled = False
Msg = "Please Enter a START Date in cell B2" ' Define message.
Style = vbOKOnly + vbDefaultButton1 ' Define buttons.
Title = "MsgBox Demonstration" ' Define title.
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
Else
Day1Button.Enabled = True
End If
End Sub
Private Sub Day1Button_Click()
Application.Run "'MACRO AT&T Traffic Studies.xls'!Day1Macro"
Day2Button.Enabled = True
Day1Button.Enabled = False
End Sub
Private Sub Day2Button_Click()
Application.Run "'MACRO AT&T Traffic Studies.xls'!Day1Macro"
Day3Button.Enabled = True
Day2Button.Enabled = False
End Sub
Private Sub Day3Button_Click()
Application.Run "'MACRO AT&T Traffic Studies.xls'!Day1Macro"
Day4Button.Enabled = True
Day3Button.Enabled = False
End Sub
Private Sub Day4Button_Click()
Application.Run "'MACRO AT&T Traffic Studies.xls'!Day1Macro"
Day5Button.Enabled = True
Day4Button.Enabled = False
End Sub
Private Sub Day5Button_Click()
Application.Run "'MACRO AT&T Traffic Studies.xls'!Day1Macro"
Day5Button.Enabled = False
Day1Button.Enabled = True
End Sub
a date present in cell B2. The script I have below works, but has some
issues. Message box comes up twice, etc..
This is part of a Large Workbook with many macros the users steps thru.
I wanted to only enable the button in the proper order. Example:
A date must be in cell B2 to enable Button-1.
Once Button-1 is pushed Button-2 is enabled and Button-1 is Disabled.
any ideas or suggestions would be appreciated.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Msg, Style, Title, Response
Sheets("Study Dates").Select
Range("B2").Select
Selection.NumberFormat = "d-mmm-yy"
If IsEmpty(ActiveCell) = True Then
Day1Button.Enabled = False
Day2Button.Enabled = False
Day3Button.Enabled = False
Day4Button.Enabled = False
Day5Button.Enabled = False
Msg = "Please Enter a START Date in cell B2" ' Define message.
Style = vbOKOnly + vbDefaultButton1 ' Define buttons.
Title = "MsgBox Demonstration" ' Define title.
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
Else
Day1Button.Enabled = True
End If
End Sub
Private Sub Day1Button_Click()
Application.Run "'MACRO AT&T Traffic Studies.xls'!Day1Macro"
Day2Button.Enabled = True
Day1Button.Enabled = False
End Sub
Private Sub Day2Button_Click()
Application.Run "'MACRO AT&T Traffic Studies.xls'!Day1Macro"
Day3Button.Enabled = True
Day2Button.Enabled = False
End Sub
Private Sub Day3Button_Click()
Application.Run "'MACRO AT&T Traffic Studies.xls'!Day1Macro"
Day4Button.Enabled = True
Day3Button.Enabled = False
End Sub
Private Sub Day4Button_Click()
Application.Run "'MACRO AT&T Traffic Studies.xls'!Day1Macro"
Day5Button.Enabled = True
Day4Button.Enabled = False
End Sub
Private Sub Day5Button_Click()
Application.Run "'MACRO AT&T Traffic Studies.xls'!Day1Macro"
Day5Button.Enabled = False
Day1Button.Enabled = True
End Sub