need to split month out from date formatted cell

  • Thread starter Thread starter John R.
  • Start date Start date
J

John R.

Hi, I have a workbook that is used throughout the company.
My boss wants to report on certain fields based on month.
The only problem is that all cells with a date in them are
all mm/dd/yy. I want to present my boss with a userform
that will ask her what month she wants, then go to any
worksheet and get the information she needs.

How can I query the date cells with only a 2 digit month?

Thanks
 
From the UserForm take the month number say in ReportMonth variable

Test this against the value in the cell (eg A1) holding the date for
selection using

If ReportMonth = Month(Range("A1")) Then
' do code - the month matches
End If

Cheers
N
 
Hi again, but the current content of the cell is say
11/21/03, and the next cell in the column is 11/25/03, the
next cell might be 07/30/02. How do I only get rows in
which the month is 11? Sorry I'm new to VB and don't quite
understand the code you have written.
 
I guess I should also tell you that I'm storing the month
she picks into x1 of my worksheet, I then have to query a
closed workbook to get the information for the month she
has picked.

I'm also using Excel 97 on a Win2k machine.
 
John

You might find that an advanced filter is what you need.
See Deborah Dalgliesh's site Contextures.com

The criterion to filter November's data would be
=MONTH(A11)=11 if the dates are in column 1 and the list
starts at row 11.

You can use an inputBox for the manager to to insert the
month number with somthing like

x = Inputbox("Enter the number of the month")
range("a2")= "=MONTH(A11)=x"

Deborah shows how to extract certain fields to another
place

Peter Atherton
 
Back
Top