Excel VBA - Coding

C

csus_tony

hello,

i put a command button on the first sheet of a template workbook and i
is my intention to put data from a web query to another sheet in th
same workbook when i press the command button created on sheet1. th
code i have is as follows:

With ThisWorkbook.Worksheets("Sheet2").QueryTables.Add(Connection:= _

"URL;http://chart.yahoo.com/table.csv?a=0&b=5&c=2004&d=0&e=5&f=2004&s=msft&y=0&g=d&ignore=.csv"
_
Destination:=Range("a6"))

.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xloverwriteclearcells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
'.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingAll
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.Refresh BackgroundQuery:=False
.TextFileCommaDelimiter = True
End With

Range("A6:A7").Select
Selection.TextToColumns Destination:=Range("A6")
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False
Tab:=False, _
Semicolon:=False, Comma:=True, Space:=False, Other:=False
FieldInfo _
:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1)
Array(5, 1), Array(6, 1), _
Array(7, 1))
Range("A7:G3").Select
Selection.Columns.AutoFit

thank you for any help you can offer.

ton
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top