WebQuery Extracting from a table

robgrant

New Member
Joined
Jul 1, 2010
Messages
31
Hey guys,

I want to create a spreadsheet that would used web query data from yahoo finance. I have three problems right now.

1) When I run a query, I'm presented with an entire table as shown below> I only need the data highlighted in yellow; possibility also the data highlighted in purple as a total to appear in one cell. Is there a way to extract this data?
Excel Workbook
EFGHI
4
5Earnings EstCurrent Qtr.Next Qtr.Current YearNext Year
640,461.0011-Jan11-Jul12-Jul
7Avg. Estimate0.400.421.731.99
8No. of Analysts36.00354227
9Low Estimate0.380.41.651.8
10High Estimate0.430.451.862.17
11Year Ago EPS0.360.41.611.73
12
Sheet1
Excel 2007


2) The data should be dynamic, and I also need to have a list of stock symbols in the left hand column. The current stock symbol shown in the example is CSCO. How do I get this to change for each line?

3) I'm also going to need to extract data from another table on a different page to make my calculation. Does this present any problems?
 
Last edited:

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Here's a starting point, from adapting some recorded code.

New worksheet, with stock codes in column H.
Place this code in a new module (Alt+F11, Insert>Module, paste)

Run by returning to the spreadsheet, pressing Alt+F8, and double-clicking the macro name

Code:
Sub GetQuote()
    Dim c As Range
    
    For Each c In Range("H:H").SpecialCells(xlCellTypeConstants, xlTextValues)
        With ActiveSheet.QueryTables.Add(Connection:= _
            "URL;http://finance.yahoo.com/q/ae?s=" & c.Value & "+Analyst+Estimates", Destination:= _
            Range("$A$1"))
            .Name = "ae?s=CSCO+Analyst+Estimates_1"
            .FieldNames = True
            .RowNumbers = False
            .FillAdjacentFormulas = False
            .PreserveFormatting = True
            .RefreshOnFileOpen = False
            .BackgroundQuery = True
            .RefreshStyle = xlOverwriteCells
            .SavePassword = False
            .SaveData = True
            .AdjustColumnWidth = True
            .RefreshPeriod = 0
            .WebSelectionType = xlSpecifiedTables
            .WebFormatting = xlWebFormattingNone
            .WebTables = "9"
            .WebPreFormattedTextToColumns = True
            .WebConsecutiveDelimitersAsOne = True
            .WebSingleBlockTextImport = False
            .WebDisableDateRecognition = False
            .WebDisableRedirections = False
            .Refresh BackgroundQuery:=False
        End With
        c.Offset(0, 1).Resize(1, 4).Value = Range("B3:E3").Value
    Next c
End Sub

Denis
 
Upvote 0

Forum statistics

Threads
1,225,521
Messages
6,185,457
Members
453,292
Latest member
Michandra02

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