Macro variations

Kflamme20

New Member
Joined
Oct 2, 2012
Messages
5
Hello, guys!
I've got a couple of issues. There's the line in the macro which goes

If Range("C" & CStr(LSearchRow)).Value = "PS MOP" Then
If Range("C" & CStr(LSearchRow)).Value = "PG MOP" Then
If Range("F" & CStr(LSearchRow)).Value >= DateSerial(2012, 10, 1) Then
If Range("F" & CStr(LSearchRow)).Value <= DateSerial(2012, 10, 31) Then

but it doesn't function, because Range C has two values. I tried it with a "*", still doesn't function.

1). Is there a way to unite a couple of values in Range C
2). and can Range F be directed to a certain cell in a worksheet?

Thanks.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Welcome to the board. Your query is not clear at all so making a guess as to what you are asking. I think you want the code changed to:
Code:
If Range("C" & CStr(LSearchRow)).Value = "PS MOP" Or Range("C" & CStr(LSearchRow)).Value = "PG MOP" Then
  If Range("F" & CStr(LSearchRow)).Value >= DateSerial(2012, 10, 1) AND Range("F" & CStr(LSearchRow)).Value <= DateSerial(2012, 10, 31) Then
     ' Something your code should do
  End If
End If
If you want Range F to be directed to a specific cell, you should use Range("B3"), changing B3 to whatever address you are trying to direct to
 
Upvote 0
Welcome to the board. Your query is not clear at all so making a guess as to what you are asking. I think you want the code changed to:
Code:
If Range("C" & CStr(LSearchRow)).Value = "PS MOP" Or Range("C" & CStr(LSearchRow)).Value = "PG MOP" Then
  If Range("F" & CStr(LSearchRow)).Value >= DateSerial(2012, 10, 1) AND Range("F" & CStr(LSearchRow)).Value <= DateSerial(2012, 10, 31) Then
     ' Something your code should do
  End If
End If
If you want Range F to be directed to a specific cell, you should use Range("B3"), changing B3 to whatever address you are trying to direct to

Thank you, I think "Or" would function in that manner. As for DateSerial, it works even with double If, I just meant to mention a cell in a worksheet with current date io changing constantly the dates by hand each month.
 
Upvote 0
What do you mean that it has 2 values?
 
Upvote 0
What exactly is in the cell(s)?
 
Upvote 0
What exactly is in the cell(s)?

I don't want to change the date manually, I'd like to put it in a cell and make reference in the macro to that cell.
The result must meet two values in a range, either PS or PG and not just one.
 
Upvote 0
Sorry, I thought you said there were two values in the cell?

Are you now saying there are 2 possible values in the cell?

What exactly is the logic of the code?
 
Upvote 0
Norie, he's not being very clear, I think he's asking for a macro to act IF a cell in column C is either value "PS MOP" or "PG MOP" and the date in the equivalent row in column F lies between a date range.

The date range is currently hardcoded in the macro code and he wants to change this, so the code references a cell that contains the date, which means later, he can change the date on the worksheet without needing to update the macro code itself. I think that's what he's after anyway, could be very wrong!

Kflamme - the more clear and precise you can be, easier it is to answer
 
Last edited:
Upvote 0
Norie, he's not being very clear, I think he's asking for a macro to act IF a cell in column C is either value "PS MOP" or "PG MOP" and the date in the equivalent row in column F lies between a date range.

The date range is currently hardcoded in the macro code and he wants to change this, so the code references a cell that contains the date, which means later, he can change the date on the worksheet without needing to update the macro code itself. I think that's what he's after anyway, could be very wrong!

Kflamme - the more clear and precise you can be, easier it is to answer

You're quite right as to the date, but not as to other values.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top