msg box pops up when button is clicked in certain cell

apicsofcake

New Member
Joined
Sep 23, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Worksheet("Sheet1").Range("A:AE").NumberFormat = "dd/mmm/yy hh:mm AM/PM" Then
If timeStamp_Click = True Then
MsgBox "are you sure?"
End If
End Sub

//I want to fulfill two conditions,

First, when the cell within range A:AE, any of them is filled with timestamp

Then, when user clicks on timeStamp button, msg pops up

I don't know why the above codes don't work

Can somebody help with this?
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
will this work for you
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If ActiveCell.Value <> "" Then


If ActiveCell.NumberFormat = "dd/mmm/yy hh:mm AM/PM" Then

MsgBox "are you sure?"
End If
End If
End Sub
 
Upvote 0
will this work for you
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If ActiveCell.Value <> "" Then


If ActiveCell.NumberFormat = "dd/mmm/yy hh:mm AM/PM" Then

MsgBox "are you sure?"
End If
End If
End Sub

For timeStamp button click, it’s always highlighted. Is their alternative codes for clicking? Thanks
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,818
Members
449,049
Latest member
cybersurfer5000

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
Back
Top