Issue with IF statement running off a dropbox

Chardo

New Member
Joined
Feb 11, 2014
Messages
3
Hello,

Currently I have a dropbox that allows the user to choose:
Hong Kong
London
Berlin


I have an If statement that determines what address to display dependent upon the city chosen from the dropbox. My issue is that the formula seems to work but requires me to actually click into the formula and then hit enter to get it to actually register the change within the dropbox.

Is there a way around this problem? I attempted to use a vba (code below) but that doesn't seem to work either. Any help is greatly appreciated.

Sub updateifs()


If Range("location") = "Hong Kong" Then
Range("A2") = "Middle Road / Nathan Road, Hong Kong, Kowloon, Hong Kong"
Else
If Range("location") = "London" Then
Range("A2") = "30 Portman Square London W1H 7BH United Kingdom"
Else
Range("A2") = "Eichhornstrabe Berlin Germany"
End If
End If
If Range("location") = "Hong Kong" Then
Range("A3") = "8A Hart Avenue Hong Kong Kowloon Hong Kong"
Else
Range("A3") = ""
End If
If Range("location") = "Hong Kong" Then
Range("A4") = "1 Hanoi Road Tsim Sha Tsui Kowloon"
Else
Worksheets("Google Street View").Range("A4") = ""
End If


End Sub

^Based on:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Target.Worksheet.Range("H5")) Is Nothing Then
Sheet18.updateifs
End If

End Sub
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
try this clean up of your nested ifs

Code:
Sub updateifs()
    If Range("location") = "Hong Kong" Then
        Range("A2") = "Middle Road / Nathan Road, Hong Kong, Kowloon, Hong Kong"
        Range("A3") = "8A Hart Avenue Hong Kong Kowloon Hong Kong"
        Range("A4") = "1 Hanoi Road Tsim Sha Tsui Kowloon"
    ElseIf Range("location") = "London" Then
        Range("A2") = "30 Portman Square London W1H 7BH United Kingdom"
        Range("A3") = ""
        Range("A4") = ""
    Else
        Range("A2") = "Eichhornstrabe Berlin Germany"
        Range("A3") = ""
        Range("A4") = ""
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,173
Members
451,543
Latest member
cesymcox

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