Date calculations and Macros

O_2

New Member
Joined
Feb 9, 2003
Messages
4
I am having some difficulty with a macro that runs when a specific file is opened. What I need is for the macro to check the difference between the date the file was last updated (stored in cell A52) and the current date (which I have currently stored in A54 as the formula TODAY()).

Both cells are set to the same type and I have added a third option (cell A57) which does the calculation A54-A52 (set to type General). The macro is below, but I can't seem to get it to work properly. Does anyone know what I am doing wrong? The second option (displaying the message) seems to work and if I replace it with the Workbook.Close command it will run then but it doesn't run the first check at all (chances are I am referencing the IF Check incorectly but for the life of me I can't find the correct reference).

I appreciate any help that people can provide.


Sub Auto_Open()

If (R57C1) > 30 Then

ActiveWorkbook.Close savechanges:=False

Else

Range("B3").Select
MsgBox ("<MESSAGE>")

End If
End Sub
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Hi O_2:

Let us first change ...

If (R57C1) > 30 Then

to

If [A57] > 30 Then
or
If Cells(57,1) >30 Then
 
Upvote 0

Forum statistics

Threads
1,221,709
Messages
6,161,432
Members
451,705
Latest member
Priti_190

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