Thanks Matt,
This was helpful.
As I said the report is run quarterly, i.e. March, June, September and
December.
The report has 23 spreadsheets for each division, so the "response" will
work magnificently until the macro gets too large and then I'll have to call
another macro to run similarly for the remainder of the divisions, the user
will then have to input the current quarter again.
Is there a way, for example, that I can add an IF - like if current month =
"March" look for Q1 and so forth? Thank you
- Show quoted text -
Clarissa,
In the VBE Help section, search "Select Case Statement" and
"If...Then...Else Statement," and you should find what you need. In
short, if you pull the current month in (whether from the ActiveCell
or from an InputBox), you can run the value through a Case Statement
to output what you want. The following should help lead you in the
right direction. By the way, I'm not sure what you mean by "...until
the macro gets too large..." (Don't discount the ability of Excel).
If the quarter END is Mar, Jun, Sep, and Dec (i.e. the fiscal year end
is Dec).
Option Explicit
Sub findQuarters()
Dim response
Dim findTxt
Dim monthDate
monthDate = Format(DateSerial(Year(Date), Month(Date), Day(Date)),
"mmmm")
response = InputBox("Input the current month","Current
Month",monthDate)
'note: you'll probably want to validate that the input text is valid
Select Case response
Case "January"
findTxt = "Q1"
Case "February"
findTxt = "Q1"
Case "March"
findTxt = "Q1"
Case "April"
findTxt = "Q2"
Case "May"
findTxt = "Q2"
Case "June"
findTxt = "Q2"
Case "July"
findTxt = "Q3"
Case "August"
findTxt = "Q3"
Case "September"
findTxt = "Q3"
Case "October"
findTxt = "Q4"
Case "November"
findTxt = "Q4"
Case "December"
findTxt = "Q4"
End Select
Cells.Find(What:=findTxt).Activate
'Find has a lot more parameters than just "What"
''Also, keep in mind that you need to code something that
''will work if "findTxt" is Nothing.
'then once the cell is found you can output the values by using
something
'like ActiveCell.Offset(row,col).Value = .....
End Sub