Not getting the object structure of VBA Excel
Tom Ogilvy wrote:
I don't understand the question and the only code you provided was the one
line.
I don't see how the workbook_open event fits into this scenario you
describe:
For instance I import some data into the first sheet, then I try to
delete the first column, since I don't need the data,
Seems like deleting a column would occur after the workbook_open had
completed.
Tom,
I am new to programming excel, please forgive my ignorance. Basically
what I am trying to do is load data into a work sheet from a website.
After the data is loaded, I intend to then reformat it, delete un needed
data columns, convert meters to feet etc. My thought is to do all this
in the workbook open event, to use that as the master control for the
whole program. Below is my code so far, I think this will give you a
better perspective on what's going on
Private Sub Workbook_Open()
Dim mMonth
Dim mDay
Dim mYear
mYear = year(FormatDateTime(Now, vbShortDate))
mMonth = month(FormatDateTime(Now, vbShortDate))
mDay = day(FormatDateTime(Now, vbShortDate))
Sheet1.Columns.Clear
Dim dinky As QueryTable
mConnectionString =
"URL;http://weather.uwyo.edu/cgi-bin/sounding?region=naconf&TYPE=TEXT%3ALIST&"
mConnectionString = mConnectionString +
"YEAR=2005&MONTH=01&FROM=2700&TO=2700&STNM=723 65"
Set dinky =
Sheet1.QueryTables.Add(mConnectionString,Applicati on.Range("A2:Z2"))
While dinky.Refreshing
'do nothing
Wend
With dinky
.WebSelectionType = xlSpecifiedTables
.WebTables = "1"
.WebPreFormattedTextToColumns = True
.Refresh
End With
'once data is loaded into the page, start cleaning it up i.e.
'ThisWorkbook.Sheets(1).Columns(1).delete
End Sub
|