Converting multiple if then statements to select case

LuluZulu

New Member
Joined
Jan 16, 2013
Messages
8
Hi, I am hoping someone can help here, I performed a search but did not see a result specific to my issue. We are pulling data from a database with several columns. Column A has country and column B has a subsidiary. Unfortunately, due to a bug in the system the countries don't appear, so in the interim I have created 3 if then statement as follows:

=IF(B2="company a","country 1",IF(B2="company b","country 2",IF(B2="company c","country 3",IF(B2="company d","country 4", etc

I would like to convert all 3 statements into a select case to make this process a little easier, but sadly my attempts have failed. I would be very grateful if someone can help.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
hey..

may be something like this will work for you....

I have considered as you have selected the range where you want the Country name and the company name is in next column

like You have selected Range A1:A5 and company name is in B1:B5


use below code in addition to previous function
Sub enterFormula()

Dim rng As Range, rn As Range


Set rng = Selection

For Each rn In rng
rn.Formula = "=CountryNm(" & rn.Offset(0, 1).Address & ")"
Next

End Sub
 
Upvote 0
just change 100 to 100000 as many as u like.. enjoy..

That worked sky!!! Thank you so much, I really appreciate it!!

Paddy, there is no set range for the company name, it changes on a weekly basis. However, I can use your earlier UDF for smaller files and I can use sky's for the big beast. You guys are wonderful, thanks again!!!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,275
Messages
6,171,126
Members
452,381
Latest member
Nova88

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