Using a function in a macro to "snapshot" a report

jdowski

Board Regular
Joined
Apr 21, 2002
Messages
235
Hi Excel...er, I mean Access Experts,

I have created a function called dateSnap()

Function dateSnap()

dateSnap = Format(Now(), "mm/dd/yy hh:mm AM/PM")

End Function

My function works fine by itself.
Now I would like to use this function within a macro using the Output to statement to "snap" out some exception reports each month. We run the reports 5 or 6 times a day sometimes and I need to be able to track the different reports as we adjust data.

In the macro I am typing the following below where it asks for Output File:

="C:\MIS\Snapshot Reports\Exception Reports\12_MissingOfficer " & datesnap() & ".snp"

But my macro keeps bombing. This is just one report I experimenting with. I have literally dozens more to do this with once I get this problem ironed out.

Thanks,

Joe in Oxford, CT. USA.
Power just came back @ 4:50am this morning..... :eek:
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Re: Using a function in a macro to "snapshot" a re

You could try to call the variable when outputiing the file and not call the variable setting function:

In the macro I am typing the following below where it asks for Output File:

="C:\MIS\Snapshot Reports\Exception Reports\12_MissingOfficer" & datesnap & ".snp"

If that fails try creating datesnap just before you output the file...
 
Upvote 0
Re: Using a function in a macro to "snapshot" a re

Thanks RossLaw,

I found out what it was. My format statement was creating a date/time format that includes "/" and ":" both of which apparently are no-no's for naming comventions. Once I got rid of those the rest of my statement works fine. :cool:

Thanks again !!

J.
 
Upvote 0

Forum statistics

Threads
1,221,551
Messages
6,160,460
Members
451,648
Latest member
SuziMacca

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