+ Reply to Thread
Results 1 to 9 of 9

Based on listbox values, go to a URL in webbrowser containing those listbox values

  1. #1
    Registered User
    Join Date
    02-10-2014
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2003
    Posts
    19

    Based on listbox values, go to a URL in webbrowser containing those listbox values

    I have a user form with a listbox of several different values (say a, b, and c) on one page.
    This user form has multiple pages, and one of the multipages is called "Google Search".
    When the user clicks the tab "Google Search", I want the webbrowser on that page to direct to "https://www.google.com/search?q=a,b,c" if "a, b, c" are the values in the listbox currently.

    Think anybody could help me out? I'm assuming I need to declare all the values in the listbox as variables, and somehow attach those variables to the URL.


    If you need more information on the code, please let me know!

    Thank you

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Based on listbox values, go to a URL in webbrowser containing those listbox values

    You would make a string of the selected listbox items and append it to the google search url.

    Maybe something like this...

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    02-10-2014
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: Based on listbox values, go to a URL in webbrowser containing those listbox values

    Nice! That takes care of the hard part -
    Now is there anyway instead of a command button, when you click the tab for a different page the webbrowser goes to that strURL?
    My code for just the general google.com page is:


    Private Sub mpgContainer_Change()
    If mpgContainer.Value = 5 Then
    wbrWeb.Visible = True
    Else
    wbrWeb.Visible = False
    End If
    End Sub

    Private Sub UserForm_Initialize()
    wbrWeb.Silent = True
    wbrWeb.Visible = False
    wbrWeb.Navigate "www.google.com"
    End Sub

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Based on listbox values, go to a URL in webbrowser containing those listbox values

    Quote Originally Posted by krisspy View Post
    Nice! That takes care of the hard part -
    Now is there anyway instead of a command button, when you click the tab for a different page the webbrowser goes to that strURL?
    My code for just the general google.com page is:


    Private Sub mpgContainer_Change()
    If mpgContainer.Value = 5 Then
    wbrWeb.Visible = True
    Else
    wbrWeb.Visible = False
    End If
    End Sub

    Private Sub UserForm_Initialize()
    wbrWeb.Silent = True
    wbrWeb.Visible = False
    wbrWeb.Navigate "www.google.com"
    End Sub
    You're welcome.

    In your post above, surround your pasted code with CODE tags. They will bust you for not doing that. See my signature block below.

    Put the code I gave right after wbrWeb.Visible = True.
    Replace the MsgBox with the Navigate command and strURL

  5. #5
    Registered User
    Join Date
    02-10-2014
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: Based on listbox values, go to a URL in webbrowser containing those listbox values

    Is there a way to make it so the string contains ALL of the items in the listbox, not just the selected ones?
    I really do appreciate this help!

    (And thumbs up to the heads up about the code tags)

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Based on listbox values, go to a URL in webbrowser containing those listbox values

    Quote Originally Posted by krisspy View Post
    Is there a way to make it so the string contains ALL of the items in the listbox, not just the selected ones?
    I really do appreciate this help!

    (And thumbs up to the heads up about the code tags)
    Just one line to construct the URL string.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    02-10-2014
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: Based on listbox values, go to a URL in webbrowser containing those listbox values

    Well I found some way to butcher your code because what I am trying is not working. The page that comes up when I click the tab says the page does not exist. Here is what I am working with:

    Please Login or Register  to view this content.

  8. #8
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Based on listbox values, go to a URL in webbrowser containing those listbox values

    Change the name of the listbox to suit.

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    02-10-2014
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: Based on listbox values, go to a URL in webbrowser containing those listbox values

    Thank you for your kind help, AlphaFrog. I got it running

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Trouble copying autofilter data to listbox based on combobox values
    By Blackbeginnings in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-26-2013, 10:48 AM
  2. [SOLVED] Filter Listbox Values based on Textbox input
    By redocs in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-17-2013, 04:59 AM
  3. [SOLVED] excel vba filter values to listbox from combobox and save edit values in textbox
    By breadwinner in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-03-2013, 08:42 AM
  4. Is it possible to limit a listbox based on a range to only retrieve distinct values?
    By Gvsandrs in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-15-2013, 11:58 AM
  5. [SOLVED] Copy rows to another workbook based on Listbox values returned
    By jomili in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-14-2009, 12:05 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1