Good Afternoon All,
I am currently working on a macro that updates daily performance numbers. The data itself is housed in differnet tables in different access databases. It is very time consuming to get this data from the different areas and fill in the report. I have a macro that opens access and runs the different query's which export to excel sheets then updates the report. The problem I have is the query's this information is taken from, pulls from a table that houses historical data for the whole year. I have prompts on the query that ask you for a date range you want the data for. Right now when I run the macro it opens access you enter the date ranges, it then exports the data and closes access. The issue is that it runs 6 - 7 different query's which means you would have to enter your date range 6-7 times. Is there a way to have excel fill in those input boxes for the user without them having to type it in themselves. The date range would always be the first of the month to the current day. Which I have code for in a seperate macro.
Dim firstmonth As String
firstmonth = Date - Day(Date) + 1
Dim filedate As String
filedate = Format(Date, "m/d/yyyy")
I would like this to appear at the begingin of the macro that pulls the access data so that it fills in the first box(which asks for "Start Date") with the "firstmonth" string, and then the second box(which asks for the "End Date") with the "filedate" string.
Sub AgeData()
'******************************************************
'**********************RIT Aging***********************
'******************************************************
Application.DisplayAlerts = False
Dim oApp As Object
Dim LPath As String
LPath = "C:\Aging\Aging.mdb"
Set oApp = CreateObject("Access.Application")
oApp.Visible = True
oApp.OpenCurrentDatabase LPath
oApp.DoCmd.RunMacro "SCRITAGE"
oApp.Visible = False
Windows("Fraud Scorecard.xls").Activate
Sheets("RIT Age").Range("A2:G1000").ClearContents
Workbooks.Open Filename:= _
"C:\Reports and Trending\RCSN Data\RIT Age.xls"
Windows("RIT Age.xls").Activate
Sheets("SC Aging RIT").Activate
ActiveSheet.UsedRange.Copy
Windows("Fraud Scorecard.xls").Activate
Sheets("RIT Age").Activate
Range("A1").PasteSpecial
Range("A1").Select
Windows("RIT Age.xls").Close
'******************************************************
'**********************ASG Aging***********************
'******************************************************
Application.DisplayAlerts = False
LPath = "C:\Aging\Aging.mdb"
Set oApp = CreateObject("Access.Application")
oApp.Visible = True
oApp.OpenCurrentDatabase LPath
oApp.DoCmd.RunMacro "SCASGAGE"
oApp.Visible = False
Windows("Fraud Scorecard.xls").Activate
Sheets("ASG Age").Range("A2:G1000").ClearContents
Workbooks.Open Filename:= _
"C:\Reports and Trending\RCSN Data\ASG Age.xls"
Windows("ASG Age.xls").Activate
Sheets("SC Aging ASG").Activate
ActiveSheet.UsedRange.Copy
Windows("Fraud Scorecard.xls").Activate
Sheets("ASG Age").Activate
Range("A1").PasteSpecial
Range("A1").Select
Windows("ASG Age.xls").Close
'******************************************************
'**********************IPT Aging***********************
'******************************************************
Application.DisplayAlerts = False
LPath = "C:Aging\Aging.mdb"
Set oApp = CreateObject("Access.Application")
oApp.Visible = True
oApp.OpenCurrentDatabase LPath
oApp.DoCmd.RunMacro "SCIPTAGE"
oApp.Visible = False
Windows("Fraud Scorecard.xls").Activate
Sheets("IPT Age").Range("A2:G1000").ClearContents
Workbooks.Open Filename:= _
"C:\Reports and Trending\RCSN Data\IPT Age.xls"
Windows("IPT Age.xls").Activate
Sheets("SC Aging IPT").Activate
ActiveSheet.UsedRange.Copy
Windows("Fraud Scorecard.xls").Activate
Sheets("IPt Age").Activate
Range("A1").PasteSpecial
Range("A1").Select
Sheets("2010 Scorecard").Range("A1").Select
Windows("IPT Age.xls").Close
MsgBox "The Aging data has been updated."
Application.DisplayAlerts = True
End Sub
Bookmarks