Use a CommandButton Control for a Google Maps Hyperlink with Cell Data

RJSIGKITS

Board Regular
Joined
Apr 15, 2013
Messages
109
Hi Board of Genius'

Can anybody help me to achieve this, at all, please?

I currently have a Hyperlink Cell (C10) which, when clicked, takes the user externally to Google maps at the address as inputted into a number of Cells:

User Cells:
B6 = "House Name / Number"
B7 = "Street"
B8 = "Town"
B9 = "County"
B10 = "Post Code"

The Hyperlink formula I have in C10 is:
Code:
=HYPERLINK("http://maps.google.com/maps?q="&SUBSTITUTE(B6&"+"&B7&"+"&B8&"+"&B9&"+"&B10," ","+"),"VIEW ON MAP")

This works fine, but I really want this to be assigned to a CommandButton Control, but just cannot figure out how to get it to work - any help would be much appreciated.

:oops:

Thanks In advance.

Kind Regards
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Comfy

Well-known Member
Joined
Dec 21, 2009
Messages
3,386
Add a command button to your workbook and paste this into the code section for the button.

Code:
Private Sub CommandButton1_Click()
ActiveWorkbook.FollowHyperlink Address:="http://maps.google.com/maps?q=" & Replace(B6 & "+" & B7 & "+" & B8 & "+" & B9 & "+" & B10, " ", "+")
End Sub
 

RJSIGKITS

Board Regular
Joined
Apr 15, 2013
Messages
109
Add a command button to your workbook and paste this into the code section for the button.

Code:
Private Sub CommandButton1_Click()
ActiveWorkbook.FollowHyperlink Address:="http://maps.google.com/maps?q=" & Replace(B6 & "+" & B7 & "+" & B8 & "+" & B9 & "+" & B10, " ", "+")
End Sub


Hey, Thanks for the Reply.
I've been playing around with this and I think I had got to the same thing (Except with .co.uk in place of your .com)
This is searching for https://maps.google.co.uk/maps?q=++++ and not the address....
 

Watch MrExcel Video

Forum statistics

Threads
1,133,428
Messages
5,658,737
Members
418,467
Latest member
sc356448

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
Top