Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to find anything "*"

Status
Not open for further replies.

chrisaroundtown

Technical User
Joined
Jan 9, 2003
Messages
122
Location
AU
Hi,

I have a table with orders in it. I will enter in a report_month and try to count records which were ordered int the same month. This is easy enough however if I want to count all orders I will enter the report_month as "Total", it should then count everything. Below is my code, I am getting zero if the report_month is "Total".

' first I decide whether to report on a single month or everything

If report_month = "Total Then
order_month = "*" 'make order_month = anything
Else
order_month = report_month
End If


'further down I count the orders that equal order_month

If ActiveCell.Value = order_month then
order_count = order_count +1
Else

End If


Any ideas on how this can be achieve simply?

Thanks
Chris
 
Have you tried to replace this:
If ActiveCell.Value = order_month then
By this ?
If ActiveCell.Value = order_month Or order_month = "*" Then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Yes it doesn't like the asterix "*", I need to count everything and in an access query I would use "*" but it doesn't seam to work in VBA.

Do you know what I should use in VBA instead?

Thanks
Chris
 
And this ?
If ActiveCell.Value = order_month Or report_month = "Total" Then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
That's the one.

Thanks for your help PHV, it turned out to be so simple. It helps just to have another pair of eyes look at it.

You just helped me turn two macros into one.

Thanks
Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top