Oct 18 2018 05:56 AM
Hello. I am a complete novice on Excel but using google and you tube I can put basic macros etc in to play. I have created a button on a spreadsheet that when clicked creates a timestamp in a cell. I now need that button to check another cells content prior to creating a timestamp.
At present the button contains this code:-
Private Sub CommandButton1_Click()
Range("F3").Value = Now()
End Sub
I am now needing it to perform the following tasks:-
1st - Check cell H3 to see if it contains the word "Available"
2nd - If Cell H3 = "Available", then open a pop up box with the message "Please allocate a task to the driver before deployment"
3rd - If cell H3 does not = "Available" then create a timestamp in cell F3
I have tried google and you tube, but everything I try seems to come up with errors. I would be grateful for any help anyone can offer me. Thank you
Oct 18 2018 07:14 AM
Solution
try:
Private Sub CommandButton1_Click()
Range("F3").Value = Now()
If Range("H3") = "Available" Then
MsgBox "Please allocate a task to the driver before deployment"
Else
Range("F3").Value = Now()
End If
End Sub
Oct 18 2018 08:39 AM
Thank you Lorenzo.
That works perfectly. Your assistance is greatly appreciated.
Oct 18 2018 07:14 AM
Solution
try:
Private Sub CommandButton1_Click()
Range("F3").Value = Now()
If Range("H3") = "Available" Then
MsgBox "Please allocate a task to the driver before deployment"
Else
Range("F3").Value = Now()
End If
End Sub