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

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

QuietRiot

Well-known Member
Joined
May 18, 2007
Messages
1,079
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
  2. MacOS
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

texasalynn

Well-known Member
Joined
May 19, 2002
Messages
8,458
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,190,883
Messages
5,983,387
Members
439,841
Latest member
goodwillhunting

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