Populating List from Items on the Web

Adroitking

Board Regular
Joined
Aug 12, 2004
Messages
122
I hope this is possible but not sure. I have a macro inside a userform that logs me onto a secure website. I would now like to import all the account names from the combobox on the website to the combobox on the userform.

Is this possible?

Looking at the source code from the website. this is what I can see

Code:
<select id="AcctList" name="AcctList" class="bodytext" onChange="javascript:SelectAcct()">

<option selected value="">Select an Account</option>

<option value='Account Name 1'> Account Name 1
<option value='Account Name 2'> Account Name 2
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
You may be able to change this to fit your page, the key is to find a tag in the HTML then count the characters to the right of that tag to your data.

You may add a loop to this to get the whole list?


Sub TickerVal()
'Run from Sheet Module!
Dim xmlhttp, Quote$, myDT$

'Create the XML document type reference.
Set xmlhttp = CreateObject("Microsoft.XMLHTTP")

'Get my range of call letters one-at-a-time from this sheet.
'Change this data range as needed!
Set rng = Range("A:A")

For Each c In rng
'Check for the last call letters in list.
If IsEmpty(c.Value) Then Exit For

'Open a connection to the server and get the call letter's web page text.
strURL = "http://finance.yahoo.com/q?s=" & Trim(c.Value) & "&d=t"
'http://finance.yahoo.com/q?s=IBM&d=t
xmlhttp.Open "GET", strURL, False, "", ""

'Send for the information needed!
xmlhttp.Send
'Return the html code page information for the call letters used.
RtnPage = xmlhttp.ResponseText

'If call letters are missing: get the next set or exit!
On Error GoTo myEnd

'If the lay-out of the web page is changed you must update the search below!
'Find the "Last Trade:" label on the web page for the current set of call letters:
myStart = InStr(RtnPage, "Last Trade:")
'The Ticker value is "52" characters right of the found label.
myDatStart = myStart + 52
'Get the actual text value from the web page!
Quote = Mid(RtnPage, myDatStart, 5)
'Print the call letters ticker value on this sheet.
c.Offset(0, 1).Value = Quote
'Print Time and date next to price.
myDT = Format(Time, "Medium Time") & " on: " & Format(Date, "General Date")
c.Offset(0, 2).Value = myDT

myEnd:
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,203,078
Messages
6,053,402
Members
444,661
Latest member
liamoohay

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
Back
Top