thank you. I try make this script.
If enter value in Sheet1.G1 ...example (GOOG,DELL)...
and CLICK command buttom.
why some problem...
(A) first click, is correct (show me A5,B5) , and changed value to "DELL"
and next click (A5,B5=DELL), but last data is move to (C5.D5=GOOG)
and next click again (A5,B5,C5,D5,E5,F5...)
what wrong ? can clean last quote value?
(B) can you tell me any method easy select table need. becuase I dull try more times..
.WebTables = 1 , wrong
.WebTables = 6 , wrong
.WebTables = 12 , wrong
.WebTables = 15 , correct
(C) if need Refresh, how to Refresh, I need use SEC, no MIN, any method ?
because I found excel, only 1 min (min), if 10sec,20sec is correct value ?
.RefreshPeriod = 1 'can change 1/2 = 30sec ?
please!
Code:
Sub gethtmltable()
Dim sQUOTE As String
Dim ds As Worksheet
Set ds = Sheets("Sheet1")
sQUOTE = ds.Range("G1").Value
Dim strConnection As String, strName As String
strConnection = "http://finance.yahoo.com/q?s=" & sQUOTE
strName = "q?s=" & sQUOTE
With ActiveSheet.QueryTables.Add(Connection:="URL;" & strConnection, Destination:=Range("A1"))
.Name = strName
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 1
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = 15
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub