Instr Function

voodoo

Board Regular
Joined
Apr 7, 2002
Messages
186
Im trying to use the Instr function to check wheteher a cell contains either of 2 values "GBP" or "GBR". Below is my code which I thought was correct but even when I am 100% sure the cell contains one of these values and I checked Length of value and it is 3, still I am getting False.

If InStr(.Cells(1, intStartRow, cVWAP_CURR_COL).Value, "GBR") = True Or _
InStr(.Cells(1, intStartRow, cVWAP_CURR_COL).Value, "GBP") = True Then

pboolBritain_GBP = True

End If

I am puzzled as to what is wrong because I have used Instr before and never had this problem.

Can anyone see anything wrong with this code or any ideas where I may be going wrong.

Thanks for any help
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

voodoo

Board Regular
Joined
Apr 7, 2002
Messages
186
Answered my own question. I should not use True or False. Also I ahd a misplaced 1 in that previous code. This worked

If InStr(.Cells(intStartRow, cVWAP_CURR_COL).Value, "GBR") Or _
InStr(.Cells(intStartRow, cVWAP_CURR_COL).Value, "GBP") Then

pboolBritain_GBP = True

End If

Silly me
 

Gates Is Antichrist

Well-known Member
Joined
Aug 15, 2002
Messages
1,961
Just a personal note - thanks for taking the trouble to give the followup even though you didn't need to. Too often it seems that question-posters never share new knowledge when they don't get a quick answer from the group.

From time to time I look up a question in Google and I hit on someone who describes exactly - I mean EXACTLY! - the same problem as I have. I gleefully click the link, and find a sad orphan question with nary a blink in its direction. (Disclaimer: except for MrExcel threads, ROFL)
 

Forum statistics

Threads
1,144,510
Messages
5,724,782
Members
422,578
Latest member
annsalinas

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
Top