Using OR and wildcard

T

Tendresse

I have a spreadsheet where columns BE and BF look something like this:

BE BF
1 Country Continent
2 From France
3 England
4 In China
5 To Brazil and others
etc.
Cells in column BE will only have one of 47 countries, but the country name
is not necessarily the first thing in the cell. It can be in the middle or
the end as well.
I want to write a VBA code that goes through column BE cell by cell, checks
if it 'contains' one of the 47 countries, then in the adjacent cell in column
BE puts the name of the continent where this country is located.
I tried to use an IF Statement (as shown below) but i got stuck on how to
use the wildcard as well as the 'OR':

Dim Y as long
For Y = 10 to 300
If cells(Y, 57).value = OR(*France*,*Italy*,*England*) then
cells(Y, 58).value = "Europe"
Else
If cells(Y, 57).value = OR(*China*,*Japan*,*singapore*) then
cells(Y, 58).value = "Asia"
Else
etc ...

I'm still fairly new with VBA and need some guidance please.
I'm using Excel 2003.
Many thanks
Tendresse
 
B

Bob Phillips

For Y = 10 To 300
If Cells(Y, 57).Value Like "*France*" Or _
Cells(Y, 57).Value Like "*Italy*" Or _
Cells(Y, 57).Value Like "*England*" Then
Cells(Y, 58).Value = "Europe"
ElseIf Cells(Y, 57).Value Like "*China*" Or _
Cells(Y, 57).Value Like "*Japan*" Or _
Cells(Y, 57).Value Like "*singapore*" Then
Cells(Y, 58).Value = "Asia"
Elseif
etc ...


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top