• Breaking News

    VBA Code For Google Map Direction

    Open a new Excel workbook. Press alt+F11  to open the visual basic window. 

    Insert user form and design it as per your need. Check the Web Brower Icon is available in the toolbox or not. If not then right-click on the toolbox and add the Microsoft web browser from the Additional controls list. 


    Put 2 labels, 2 text boxes, and 2 command buttons and below one web browser box. 


    Click on the command button 1 and write VBA Code to get direction in excel

    Private Sub GetDirection_Click()

    Me.GoogleMap.Navigate "https://www.google.com/maps/dir/" & Me.TextBox1.Value & "/" & Me.TextBox2.Value

    End Sub

    Click on the command button 2 and write the following code

    Private Sub cmdclose_Click()

    Unload Me

    End Sub

    The final code will look like thisUserform

    Now exit from the visual basic editor and create on command button in the sheet and assign the macro 

    Private Sub CommandButton1_Click()


    End Sub

    so that when you click on the command button, the user form will open like below


    You can try putting the location in 2 different text boxes. 


    You can put picture on the command button 1 if you need, else caption you can use.

    Thank You

    No comments

    View My Stats