How to Read Data from Online Web Pages with Excel VBA

This exercise shows how to read data from a website, in this case up-to-the-minute currency exchange rates from Yahoo.com.

It is assumed the reader has the Developer ribbon displayed and is familiar with the VBA Editor. If not, please Google “Excel Developer Tab” or “Excel Code Window”.

Prerequisites include a knowledge of populating combo-boxes and defining names.

The workbook consists of two sheets:

The User Interface:The User Interface

The Buy and Sell combo boxes reference the local data sheet below.

The table at D11 will be auto-pasted from the website itself, retaining user formatting.Buy And Sell Currencies

The xlsm for this exercise can be downloaded here.

Building the Application Yourself.

Create a sheet with two combo boxes. The combo boxes will reference cells on a second sheet.

The combo-boxes will also invoke the code to read the website, using the Change event.

Currency names can be pasted into the second sheet (“Currencies”) from the list below, the sort-order being a matter of personal preference:

ZAR
USD
EUR
GBP
CHF
AUD
NZD
JPY
CAD
SEK
DKK
NOK
MUR
HKD
SGD
ILS
AED
INR
CNY

Paste the data into Columns B and E.

Define Names and use Index functions as per the illustration:Buy And Sell Currencies

Since names have been defined on the local data sheet “Currencies”, sheet “Main” has merely to refer to the defined names to get the value, i.e. =SELL and =BUY for “Main” cells E10 and G10 respectively.

We will be programming Excel to read the web. It does have, however, its own built-in process on the Data ribbon, an instance of which you might like to record as a macro in building different scenarios. Note that computer or browser configurations can adversely affect web-page scripts.

The Code

Insert a module, and enter the following:

Option Explicit

Sub Ticker()
  Dim currBuy As String
  Dim currSell As String

  Range("D11:F14").ClearContents      'prepare the ground for the web data
  currBuy = Range("BUY")          'get variable values from Defined Names previously set up
  currSell = Range("SELL")
  With ActiveSheet.QueryTables.Add(Connection:= _
    "URL;http://finance.yahoo.com/q?s=" & currBuy & currSell & "=X", Destination:=Range("$D$11"))
    .Name = "q?s=" & currSell & currBuy & "=X"
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = False
    .BackgroundQuery = True
    .RefreshStyle = xlInsertDeleteCells
    .SavePassword = False
    .SaveData = True
    .AdjustColumnWidth = True
    .RefreshPeriod = 0
    .WebSelectionType = xlSpecifiedTables
    .WebFormatting = xlWebFormattingNone
    .WebTables = """table1"""
    .WebPreFormattedTextToColumns = True
    .WebConsecutiveDelimitersAsOne = True
    .WebSingleBlockTextImport = False
    .WebDisableDateRecognition = False
    .WebDisableRedirections = False
    .Refresh BackgroundQuery:=False
  End With
End sub

Sub DropDown2_Change()    'This event will call the routine above. Object name might differ.
    Call Ticker
End Sub

Sub DropDown1_Change()
    Call Ticker
End Sub

Save the workbook as type xlsm.

Test the code by changing the values of the combo boxes, then smarten up the formats of the pasted table (four decimal places, gridlines, shadings?).

Corruption of Excel files

Excel is known at times to corrupt files on saving, thereafter attempting its own self-recovery routine which often, in my experience, simply doesn’t work. This can be disastrous for the user, since it is the source file (possibly your only copy) that is destroyed. Damaged Excel files can however be repaired using third party tools, saving considerable time and effort.

Author Introduction:

Felix Hooker is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including repair rar archive and sql recovery software products. For more information visit www.datanumen.com

2 responses to “How to Read Data from Online Web Pages with Excel VBA”

  1. If you’re interested in seeing the CharmDate workplaces, for any inquiries, then you can most likely to their headquarters situated in Trust fund Company Complex, Ajeltake Road, Ajeltake Island, Majuro, Marshall Islands, MH96960. CharmDate is possessed as well as managed by a company going by the name QPid Network. Whenever you wish God to protect your 2 yr previous, do you currently presume He isn’t mosting likely to do it? Which Year It Established? It was started in 1998. The website is just one of the first online dating sites to be launched. The objective of this CharmDate testimonial was to introduce you to the globe of outstanding on the internet dating. When it comes to the people, they can join from all over the globe. CharmDate is definitely a giant of the online dating world. You can find an in-depth summary of these actions in the Dating ideas section on the website. You can find your love and also joy here!

    If you wish to drop in love without barriers you require to acquire some debts. Subscribers should use paid credit reports to send and also receive emails, connect pictures, as well as affix flowers and also presents to the messages. When I registered the page, I added them, but these photos are much from version lol, I definitely don’t know a version lol, I simply included these images, and the site has already verified them. Don’t hesitate to share some intriguing elements of your life. So don’t be stunned if you won’t obtain as much focus as you expected. On top of that, you obtain interactions without delay via women. The site has a great deal to supply from top-level safety and security, numerous chat features, as well as so many ladies to speak with. The Charmdate team are phonies and con-artists, the women’s agencies (synonymous with Charmdate team) are con-artists as well as liars, and the females who use this site are con-artists and also phonies. All these are what you’ll find in this CharmDate testimonial, keep reading to discover.

    This is not a joke, now it is possible to discover meaningful relations while being in the comfort of your flat. So there is no chance you will certainly find a fraudulent account. That is where your cam comes as it offers you the chance to appreciate this attribute. When a video clip comes in turn, given that the man wishes to see the lady, the website, Charmdate, offers a video clip formerly movie of the woman and the staff member does the writing of the discussion, when and if the guy desires to see her standing up, or wants to verify her legitimacy, they quit the video, makes justifications, that the internet is not functioning and so on and so on, THis individuals are professionals on this scenarios, I do understand this is a company and this people, their proprietors, can run it as they intend to, but something is run a respectable website, another is fraud people by acting he is in call with a lady and he is not.

    If we speak of many features, your electronic camera can can be found in helpful when it pertains to using them. The site has a variety of functions, yet the gaining factor is just how arranged each variable is. For you to gain access to complete features, you have to take on a settlement plan. A desktop variation is readily available for those that had actually prefer to access the website using their computer systems. Can I Accessibility the Site Using My PC? I suggest all individuals who are using dating sites to not hesitate to request for meeting on the start due to the fact that it is much different than on-line interaction as well as you can obtain results quicker, as it was in my case. Generally, regardless of if you are just getting your feet damp in the on-line dating globe, or if you are severe and have experience with online platforms, this is the site for everyone. In general, the programmers did fairly a good work on the web site. That is where the CharmDate internet site stands apart with the great deals of uniqueness that it brings on board. Whether you have an issue with enrollment, problems with getting credits, or simply a trouble of figuring out how the site functions, the team of experts will assist you.

  2. Men Who Regret Letting A Good Woman get away Share Their Breakup Stories

    he previously A “Grass is consistently Greener” time of truth

    coming from throwawaysaddayz: It started as a tough but amicable breakup that I begun. I felt I was not ready for a serious long term relationship and was getting ‘grass is greener’ feelings and the relationship was at a lull stage. It was my first online dating so I didn’t know what these feelings meant or how to navigate them. After a month I came creeping back to her (messaging) to ask for forgiveness and to ask if we can try again. After what was a hopeful few weeks of texting the proposal was ultimately rejected. In such a lot of words she said she was too hurt and the trust is too broken. My regret after the breakup stemmed from my feelings telling me all we really needed was time apart and that I took her as a given. That I didn’t actually do anything to fix your position when we were in a lull. That I didn’t actually speak how I was feeling. That love is far from like a Disney movie. That I couldn’t answer what an additional has that she doesn’t? So certainly, there’re all mistakes I will live with. She has stuck true to no contact aside from a few weeks when I broke contact, [url=htttps://www.linkedin.com/in/charmingdate]charmdate.com[/url] And I had hope of fixing affairs. Now I am the horrible ex who broke her heart and came crawling back only to be kicked to the curb. she has kept her dignity. i have not. My attempt to fix things probably decreased her opinion of me. So now I guess it’s several lessons learned. And i’ve met its over. but still I get shreds of hope. But I know it will probably be over. And I know it probably wasn’t meant to be, And I know if I did get back together it would probably be a disaster. And I am only feeling this fashion because I’m lonely. exactly what if? does not matter now it’s over. covering throughout a lot more than. She doesn’t care about your needs anymore and you don’t matter. She will find someone soon and she will look back and be happy it never happened. gradually so will I.

    all women vs. men and women, based on BisexualsIckiest Dating Advice of YoreMen Regrets About the One Who Got AwaySecrets Men Keep that Women Don Know AboutDating Tips for Men, By WomenThings Women Notice When They Meet a GuyOnline Dating for Men Isn AwesomeThe hardest things for Men to Explain to WomenWhat Men Should Know About Women Healththey fell for someone elsewarning signs of a toxic partner.

Leave a Reply

Your email address will not be published. Required fields are marked *