Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Using OR and wildcard

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Using OR and wildcard

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)



"Tendresse" wrote in message
...
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using the wildcard with IF DamienO New Users to Excel 5 January 29th 09 01:51 AM
wildcard JOUIOUI Excel Programming 5 July 31st 06 01:47 PM
Wildcard Robert[_30_] Excel Programming 1 May 18th 06 01:28 PM
Wildcard fugfug[_10_] Excel Programming 0 July 14th 05 12:34 PM
Wildcard kevin Excel Programming 3 May 25th 04 01:21 PM


All times are GMT +1. The time now is 05:40 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"