if else statement to select values from workbook

Posted on 2013-12-28
Last Modified: 2013-12-28
folks I have a function which activates a select from a specific workbook

Function Select Region()

' Activating GenericUser sheet

however I would like to change the sheet to be used based on the region as specified in sheet 1 i.e.

if sheet1 b1 = europe then


else if sheet1 b1 = asia then


else if sheet1 b1 = africa then


how do i correctly program this?
Question by:rutgermons
LVL 68

Expert Comment

ID: 39743589
Sub Select_Region()
  select [Sheet1!B1]
    case "europe": rg = "Region1"
    case "asia": rg = "Region2"
    case "africa": rg = "Region3"
    case else: rg = "Region4"
  End select
End Sub

Open in new window

LVL 13

Accepted Solution

Ashok earned 500 total points
ID: 39743604
Function Select_Region()
   If Sheet1.Range("B1") = "europe" Then
   ElseIf Sheet1.Range("B1") = "asia" Then
   ElseIf Sheet1.Range("B1") = "africa" Then
   End If
End Function

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now