LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Insert Zip codes into weather code

Anything inside quote marks is considered text, you the appearance of Zip
inside the URL string is just the letters Z, i, and p and has nothing to do
with the variable you named Zip. Think about it for a moment... if the code
actually worked the way you wrote it, how would you ever be able to use the
word "Zip" inside you text if it would get replaced by the assignment to the
variable of the same name? The way you do what you want is by concatenating
the variable into the text...

"URL;http://www.weather.com/weather/local/" & Zip & "lswe...etc"

Also, you cannot put a line continuation inside a text string... you have to
break the string and put the line continuation at the concatenation point to
join the strings back together. For example, if this was your string...

X = "Pretend this is a long text string that you want to break apart"

then you would do that like this...

X = "Pretend this is a long text string" & _
" that you want to break apart"

--
Rick (MVP - Excel)


"L. Howard Kittle" wrote in message
...
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=searchbo x_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


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatic weather Damian Excel Discussion (Misc queries) 6 August 27th 09 02:41 PM
Importing Weather Info kpack Setting up and Configuration of Excel 1 November 8th 08 02:54 AM
Excel 2002 : How to insert a bank row between different codes ? Mr. Low Excel Discussion (Misc queries) 4 November 14th 06 11:33 PM
Weather Chart David D Charts and Charting in Excel 3 December 5th 05 03:39 PM
Weather counting query Weather Consultancy Services Excel Discussion (Misc queries) 1 July 30th 05 10:35 PM


All times are GMT +1. The time now is 08:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"