validation date n pop up msg

ruro

New Member
Joined
Jun 18, 2012
Messages
1
I want when excel file is opened. vba verify the date. if are on a certain date (eg June 30, 2012) will display a pop-up messages that have message: "The file needs to be updated. Click OK to renew or click Cancel to view the contents of the file" ...
So in a pop-up messages have OK and Cancel buttons
If click "OK" then the excel file will be closed (
Active
Workbook
.Close
)
if click "Cancel" then open the excel file but Readonly.
Can not be made in VBA?


help me please ......:confused::confused:

Thangs b4.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
You can create a form to do this with the massage and buttons, to call when the workbook is opened insert a bit of code in the Microsoft excel Objects > this workbook (it should be visisble on the left in your editor).

A code like this should work:
Code:
Private Sub Workbook_Open()
Call form name
End Sub

it's the private sub Workbook_open that important.
 
Upvote 0
:banghead: :rofl: :help:
You can create a form to do this with the massage and buttons, to call when the workbook is opened insert a bit of code in the Microsoft excel Objects > this workbook (it should be visisble on the left in your editor).

A code like this should work:
Code:
Private Sub Workbook_Open()
Call form name
End Sub

it's the private sub Workbook_open that important.

Hi Soggy,

your code makes the userform show whenever the workbook is opened ,
but this code will do the trick :
Code:
Private Sub Workbook_Open()
If Left(Now(), 8) = "7/8/2012" Then
UserForm1.Show
End If
End Sub

but remember dear ruro when you open Visual Basic double click on "This Workbook" then
enter the code

ZAX
 
Last edited:
Upvote 0
Hi Soggy,

You know what ,I made you this code it does what you want without using a userform.

Code:
Private Sub Workbook_Open()
pop = MsgBox("THE FILE NEEDS TO BE UPDATED", vbOKCancel, "TEST")
If Left(Now(), 9) = "6/30/2012" Then
If pop = vbOK Then
ActiveWindow.Close
End If
End If
End Sub

But remember , when you want to modify the date you gotta change the letters count in the "LEFT" function too.

ZAX
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,853
Members
452,361
Latest member
d3ad3y3

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