Msgbox with date

verluc

Well-known Member
Joined
Mar 1, 2002
Messages
1,451
I want at the beginning of a macro in sheet2 a Msgbox with the date of B10 in sheet1, and with the buttons O.K. (go further) and
Cancel (exit sub)
Can someone give me a little help?
Many thnaks in advance
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

FormR

MrExcel MVP
Joined
Aug 18, 2011
Messages
6,904
Office Version
  1. 365
Platform
  1. Windows
Try:
Code:
If MsgBox(Format(Sheets("Sheet1").Range("B10"), "dd/mm/yyyy"), vbOKCancel) = vbCancel Then Exit Sub
 
Upvote 0

Snakehips

Well-known Member
Joined
May 17, 2009
Messages
5,700
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Verluc,

Try like ......

Code:
If MsgBox(Sheets("Sheet1").Range("B10"), vbOKCancel) = vbCancel Then Exit Sub
'otherwise do this....
MsgBox "Doing some other stuff..."

Hope that helps.
 
Last edited:
Upvote 0

verluc

Well-known Member
Joined
Mar 1, 2002
Messages
1,451
Tony, your code is working very fine, but I want to add the following text in the msgbox : Last working day is :
Thanks for your time.
 
Upvote 0

Snakehips

Well-known Member
Joined
May 17, 2009
Messages
5,700
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Code:
If MsgBox("Last working day is : " & Sheets("Sheet1").Range("B10"), vbOKCancel) = vbCancel Then Exit Sub
'otherwise do this....
MsgBox "Doing some other stuff..."
 
Upvote 0

FormR

MrExcel MVP
Joined
Aug 18, 2011
Messages
6,904
Office Version
  1. 365
Platform
  1. Windows
I was starting to feel a little unloved by this thread ;) so thank you Tony. Although I really should have tested if format() was really needed.
 
Upvote 0

Forum statistics

Threads
1,190,740
Messages
5,982,684
Members
439,790
Latest member
jonaust

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