Consulting

Results 1 to 3 of 3

Thread: Solved: Open URL that includes string picked up from cell

  1. #1

    Solved: Open URL that includes string picked up from cell

    Hi!

    How can I make this happen?

    1. One alters cell Range("CUSTOMER_NAME")
    2. Message box: "Do yow wish to open web browser to see the customers address?" vb Yes/No
    3. If answer "Yes" browser opens "http//www.etc_1" & Range("CUSTOMER_NAME").Value & "etc_2.com"
    Thanks in advance!

  2. #2
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    below code automatically requires confirmation to open the specified page whenever the Range("CUSTOMER_NAME")) is changed.
    put it in the code module of the worksheet which houses Range("CUSTOMER_NAME"))

    [vba]
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("CUSTOMER_NAME")) Is Nothing Then Exit Sub
    Dim resp, sUrl1$, sUrl2$, sUrl$
    sUrl1 = "http//www.etc_1"
    sUrl2 = "etc_2.com"
    sUrl = sUrl1 & Range("CUSTOMER_NAME") & sUrl2

    resp = MsgBox("Do yow wish to open web browser to see the customers address?", vbYesNo)
    If resp = vbYes Then
    ThisWorkbook.FollowHyperlink sUrl
    Else
    End If

    End Sub
    [/vba]


    if you wish to assign a button then, in a standard module;
    [vba]
    Sub open_url()

    Dim resp, sUrl1$, sUrl2$, sUrl$
    sUrl1 = "http//www.etc_1"
    sUrl2 = "etc_2.com"
    sUrl = sUrl1 & Range("CUSTOMER_NAME") & sUrl2

    resp = MsgBox("Do yow wish to open web browser to see the customers address?", vbYesNo)
    If resp = vbYes Then
    If Range("CUSTOMER_NAME") = "" Then
    MsgBox "No customer specified in cell"
    Exit Sub
    Else
    ThisWorkbook.FollowHyperlink sUrl
    End If
    Else
    End If
    End Sub
    [/vba]
    Last edited by mancubus; 06-04-2011 at 08:16 AM.
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  3. #3
    Works - great solutions!

    Actually I have incorprated both above suggestions into two different assignment in my workbook (your button suggestion in fact spared me initializing another thread in here).

    Thanks a lot Mancubus!

    Rejje

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •