ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   If...then (https://www.excelbanter.com/excel-programming/352941-if-then.html)

David R. Duggan

If...then
 
I want to use the value in a named range to determine the action to take
when clicking on a command button.

The spreadsheet has range called "Location" based on a the location (city)
of the sales rep. When clicking on a command button, how can the button
direct the individual based on this value?

Something like:??

If Range("Location").Value = "Loc1" then
do this
Else
do this
End If

DRD



Bob Phillips[_6_]

If...then
 
I would use Select Case

Select Case Range("Location").Value
Case "Loc1"
'do loc1
Case "Loc2"
'do loc2
Case Else
'do else
End Select

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"David R. Duggan" wrote in message
.. .
I want to use the value in a named range to determine the action to take
when clicking on a command button.

The spreadsheet has range called "Location" based on a the location (city)
of the sales rep. When clicking on a command button, how can the button
direct the individual based on this value?

Something like:??

If Range("Location").Value = "Loc1" then
do this
Else
do this
End If

DRD





Jim Thomlinson[_5_]

If...then
 
Probably better off with a select case statement something like this...

select case range("Location").value
case "Here"
sheets("Here").select
Range("A1").select
case "There"
sheets("There").select
Range("C10").select
case "EveryWhere"
sheets("EveryWhere").select
Range("D15").select
case else
msgbox "No such place"
End Select

--
HTH...

Jim Thomlinson


"David R. Duggan" wrote:

I want to use the value in a named range to determine the action to take
when clicking on a command button.

The spreadsheet has range called "Location" based on a the location (city)
of the sales rep. When clicking on a command button, how can the button
direct the individual based on this value?

Something like:??

If Range("Location").Value = "Loc1" then
do this
Else
do this
End If

DRD




David R. Duggan

If...then
 
That worked good. Thanks

DRD

"Bob Phillips" wrote in message
...
I would use Select Case

Select Case Range("Location").Value
Case "Loc1"
'do loc1
Case "Loc2"
'do loc2
Case Else
'do else
End Select

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"David R. Duggan" wrote in message
.. .
I want to use the value in a named range to determine the action to take
when clicking on a command button.

The spreadsheet has range called "Location" based on a the location
(city)
of the sales rep. When clicking on a command button, how can the button
direct the individual based on this value?

Something like:??

If Range("Location").Value = "Loc1" then
do this
Else
do this
End If

DRD








All times are GMT +1. The time now is 09:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com