jmcconnell
New Member
- Joined
- Feb 2, 2019
- Messages
- 35
I've currently got an Active X combobox contained in a spreadsheet.
At the moment the code behind the button 'GotoSite' uses a load of IF statements where the URLs are listed in the code itself as shown in the example below (URLs have been changed for privacy so are just examples)
Private Sub GotoSite_Click()
ChromeLocation = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" 'Location of Chrome.exe in your PC
If SiteList = "BBC" Then
Shell (ChromeLocation & " -url BBC - Homepage")
ElseIf SiteList = "Amazon" Then
Shell (ChromeLocation & " -url Amazon.com: Online Shopping for Electronics, Apparel, Computers, Books, DVDs & more")
ElseIf SiteList = "Mr Excel" Then
Shell (ChromeLocation & " -url Amazon.com: Online Shopping for Electronics, Apparel, Computers, Books, DVDs & more")
End If
End Sub
Rather than have the URL within the code along with a load of IF statements, is it possible to simplify this and to have the URLs listed within the 'Website' worksheet in column B - alongside the corresponding data in column A?
Thank you in advance!
- Combobox is called SiteList
- Combobox is poulated via listfill - The list of data is in column A of a worksheet called 'website'
- The combobox itself is contained within a worksheet called' SiteShortcuts'
- there is a button below the combobox called 'GotoSite'
- Default web browser is Chrome
At the moment the code behind the button 'GotoSite' uses a load of IF statements where the URLs are listed in the code itself as shown in the example below (URLs have been changed for privacy so are just examples)
Private Sub GotoSite_Click()
ChromeLocation = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" 'Location of Chrome.exe in your PC
If SiteList = "BBC" Then
Shell (ChromeLocation & " -url BBC - Homepage")
ElseIf SiteList = "Amazon" Then
Shell (ChromeLocation & " -url Amazon.com: Online Shopping for Electronics, Apparel, Computers, Books, DVDs & more")
ElseIf SiteList = "Mr Excel" Then
Shell (ChromeLocation & " -url Amazon.com: Online Shopping for Electronics, Apparel, Computers, Books, DVDs & more")
End If
End Sub
Rather than have the URL within the code along with a load of IF statements, is it possible to simplify this and to have the URLs listed within the 'Website' worksheet in column B - alongside the corresponding data in column A?
Thank you in advance!
Last edited: