L
L. Howard Kittle
Helo Excel users and experts,
Excel 2002 SP3
The code below is supposed to return a short weather update from the area of
the zip code. It does not work, and no error prompt is given. If I remove
the two words "Zip" and type in 97401 in their place I will get the weather
update just fine..
I have a list of zip codes in a drop down in D1 of the worksheet. As you
can see I'm trying to Dim that D1 value as Zip to insert a new selected zip
code for different regional updates.
I've tried dimming as Long, and as String and used "Zip", Zip, &Zip& to no
avail.
How do I change the zip code in the weather code??
(By the way, you will see a double line break, _ _ in the "With
ActiveSheet.QueryTables..." line. I put it there for this post only as that
line of code does not accept a line break in the editor past the one already
there after "(Connection:= _".)
Sub SomeWx()
Dim Zip As Long
Zip = Range("D1").Value
Range("A1:B5").ClearContents
Range("A1").Value = "Eugene"
Range("C1") = Now()
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.weather.com/weather/local/Zip? _ _
lswe=Zip&lwsa=WeatherLocalUndeclared&from=searchbox_localwx""" _
, Destination:=Range("$A$2"))
.PreserveFormatting = True
.WebTables = "15"
.Refresh BackgroundQuery:=False
End With
End Sub
Perhaps I may have to use a select case set up with the various zip codes
hardcoded for each region.
Thanks for any help or suggestions.
Regards,
Howard
Excel 2002 SP3
The code below is supposed to return a short weather update from the area of
the zip code. It does not work, and no error prompt is given. If I remove
the two words "Zip" and type in 97401 in their place I will get the weather
update just fine..
I have a list of zip codes in a drop down in D1 of the worksheet. As you
can see I'm trying to Dim that D1 value as Zip to insert a new selected zip
code for different regional updates.
I've tried dimming as Long, and as String and used "Zip", Zip, &Zip& to no
avail.
How do I change the zip code in the weather code??
(By the way, you will see a double line break, _ _ in the "With
ActiveSheet.QueryTables..." line. I put it there for this post only as that
line of code does not accept a line break in the editor past the one already
there after "(Connection:= _".)
Sub SomeWx()
Dim Zip As Long
Zip = Range("D1").Value
Range("A1:B5").ClearContents
Range("A1").Value = "Eugene"
Range("C1") = Now()
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.weather.com/weather/local/Zip? _ _
lswe=Zip&lwsa=WeatherLocalUndeclared&from=searchbox_localwx""" _
, Destination:=Range("$A$2"))
.PreserveFormatting = True
.WebTables = "15"
.Refresh BackgroundQuery:=False
End With
End Sub
Perhaps I may have to use a select case set up with the various zip codes
hardcoded for each region.
Thanks for any help or suggestions.
Regards,
Howard