Check File Date And Abort Macro.

donlincolnmre2

Board Regular
Joined
Dec 23, 2006
Messages
142
Hello

I have a Data file, which contains the Date the file was created in column A, If that date is Less then Today's date then the macro should abort.



Here is the Data.
t
ABCDEFGH
1VolumeindriveCisDSK1_VOL1
2VolumeSerialNumberis4020-0800
3
4DirectoryofC:\WINDOWS\DESKTOP\PROSPE~1\TEST
5
68/6/20076:46AM20,998s1.pdf
71File(s)20,998bytes
80Dir(s)########bytesfree
9VolumeindriveCisDSK1_VOL1
10VolumeSerialNumberis4020-0800
11
12DirectoryofC:\WINDOWS\DESKTOP\PROSPE~1\TEST
13
148/6/20076:45AM2,375,757t1.pdf
151File(s)2,375,757bytes
160Dir(s)########bytesfree
17
t
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Code:
Sub macro1()
x = Range("A65536").End(xlUp).Row
If Cells(x, 1).Value <> Date Then Exit Sub
MsgBox "bla bla macro still running"
'code that you want to run on same day only.. 
End Sub
 
Upvote 0
try something like this:
Code:
Sub DCheck()
DCk = Format(Date, "m/d/yyyy")
If Range("A6").Text < DCk Then
MsgBox "Date is Less Than Today - Exit macro"
Exit Sub
End If
'your code here to continue
End Sub

edit: change to format to match text to text
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,391
Members
449,080
Latest member
Armadillos

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