grunschlange
New Member
- Joined
- Sep 12, 2009
- Messages
- 13
Good morning.
I have files with macros that list overdue cases in our offices. We have 6 offices--each handles what we code as "F" cases and "A" cases. So, for example, Office 1 has a file for overdue "F" cases and one for overdue "A" cases, therefore totalling 12 files that I am working with.
A sample of the macro (taken from an "F" case file) is below:
Sheets("F Cases").Select
Range("A1").Select
Dim FilterRange As Range
Dim CopyRange As Range
Dim D As Date
Set FilterRange = Range("M1:M5000") 'Header in row
Set CopyRange = Range("A1:N5000")
D = InputBox("Enter the last day of the current report month (m/d/yyyy).", "Date Selection")
FilterRange.AutoFilter Field:=1, Criteria1:="<" & D
CopyRange.SpecialCells(xlCellTypeVisible).Copy _
Destination:=Worksheets("Overdue F Reviews").Range("A3")
Application.CutCopyMode = False
Sheets("F Cases").Select
Selection.AutoFilter
Application.Goto Reference:="R1C1"
Sheets("Overdue F Reviews").Select
Application.Goto Reference:="R1C1"
The input box therefore pops up 12 times when I run all office files each month. I believe I saw once that a public variable could be used once and it would be read in the code for all modules. I would like to input the date once and each file then runs with that same date variable. How do I set this up? Do I declare the public variable in a regular module, or is there a special place to put it? I would like to use that same variable "D" for date, if possible.
If it helps any, each office has it's own folder in my C:\ drive (i.e. a folder entitled "Office 1", "Office 2", etc.). Within each folder are the lists (i.e. one entitled "Office1OverdueFReviews.xls", "Office1OverdueAReviews.xls", "Office2OverdueFReviews.xls", etc.).
Thanks for any help you can give.
I have files with macros that list overdue cases in our offices. We have 6 offices--each handles what we code as "F" cases and "A" cases. So, for example, Office 1 has a file for overdue "F" cases and one for overdue "A" cases, therefore totalling 12 files that I am working with.
A sample of the macro (taken from an "F" case file) is below:
Sheets("F Cases").Select
Range("A1").Select
Dim FilterRange As Range
Dim CopyRange As Range
Dim D As Date
Set FilterRange = Range("M1:M5000") 'Header in row
Set CopyRange = Range("A1:N5000")
D = InputBox("Enter the last day of the current report month (m/d/yyyy).", "Date Selection")
FilterRange.AutoFilter Field:=1, Criteria1:="<" & D
CopyRange.SpecialCells(xlCellTypeVisible).Copy _
Destination:=Worksheets("Overdue F Reviews").Range("A3")
Application.CutCopyMode = False
Sheets("F Cases").Select
Selection.AutoFilter
Application.Goto Reference:="R1C1"
Sheets("Overdue F Reviews").Select
Application.Goto Reference:="R1C1"
The input box therefore pops up 12 times when I run all office files each month. I believe I saw once that a public variable could be used once and it would be read in the code for all modules. I would like to input the date once and each file then runs with that same date variable. How do I set this up? Do I declare the public variable in a regular module, or is there a special place to put it? I would like to use that same variable "D" for date, if possible.
If it helps any, each office has it's own folder in my C:\ drive (i.e. a folder entitled "Office 1", "Office 2", etc.). Within each folder are the lists (i.e. one entitled "Office1OverdueFReviews.xls", "Office1OverdueAReviews.xls", "Office2OverdueFReviews.xls", etc.).
Thanks for any help you can give.