Enable a command button only after another is clicked

hyd1956

New Member
Joined
Jun 26, 2020
Messages
41
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi

Is there a way to make commandbutton1 dependant on commandbutton2 being clicked first and for to include a timer. e.g. click button 2 then you have 1 minute to click button 1 or you have to restart the process. I also need certain values to be entered into cells for each button to be enabled. So far I've got this which enables them when the values are entered, but it doesn't make button 1 dependant on button being pressed.

Any help would be greatly appreciated.

Private Sub CommandButton1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
CommandButton1.Enabled = False
If Application.CountA(Range("B1, B2, F2, F3, F4, F5, F6")) >= 7 Then
CommandButton1.Enabled = True
End If
End Sub
Private Sub CommandButton2_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
CommandButton2.Enabled = False
If Application.CountA(Range("B1, B2")) >= 2 Then
CommandButton2.Enabled = True

End If
End Sub

Thank you
 

Some videos you may like

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

mole999

Moderator
Joined
Oct 23, 2004
Messages
10,524
Office Version
  1. 2019
  2. 2016
  3. 2013
Platform
  1. Windows
set its property to hidden, and as part of the click routine unhide it
 

braindiesel

Well-known Member
Joined
Mar 16, 2009
Messages
560
Office Version
  1. 365
  2. 2019
  3. 2010
Platform
  1. Windows
Instead of enabling, you could set an external reference point... this could solve the timer as well..
command button 2
range("M1").formula = "=now()"
range("M1").value = range("M1").value
<rest of command button 2 code>

command button 1
if range("M1").value = "" then
msgbox("Please press button 1 first")
exit sub
endif
range("M2").formula = "=now()"
range("M2").value = range("M2").value
if range("M2").value - range("M1").value >60 then
msgbox("Task must be completed within 60 seconds. Please start over")
range("M1:M2").value =""
Exit sub
Else
<rest of command button 1 code>
End if


Something like that?
 

hyd1956

New Member
Joined
Jun 26, 2020
Messages
41
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Thanks, this has helped me tweak it to work
 

Watch MrExcel Video

Forum statistics

Threads
1,127,632
Messages
5,625,998
Members
416,149
Latest member
Bigpotato 668

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
Top