Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default reading variable "from" and "to" ZIP codes

How do I tell the macro to use a "from" and "to" ZIP code
range from a list of ZIP codes that reside in a worksheet?

At the bottom of this post is my macro. Part of it is:
AND (IINFO.I_ZIP='00601' And IINFO.I_ZIP<='99999') AND

But rather than specifying 00601 and 99999 in the macro, I
want it to look at the ZIP code that resides in cells A1
(from) and B1 (to) in a worksheet called "By ZIP" So, I
imagine that Range("By ZIP!A1") and Range("By ZIP!B1") is
involved somehow, but I can't figure it out.

Thanks, in advance. Dan


With ActiveSheet.QueryTables.Add(Connection:=Array
(Array( _
"ODBC;DSN=V1DATA;Description=Crystal Reports
Data;UID=dwasser;APP=Microsoft®
Query;WSID=DWASSER;DATABASE=V1Data;Trusted_Connect ion=Ye" _
), Array("s;AnsiNPW=No")), Destination:=Range
("A1"))
.CommandText = Array( _
"SELECT STAY.S_ADATE, IINFO.I_ZIP, STAY.S_STATUS,
STAY.S_NIGHTS" & Chr(13) & "" & Chr(10) & "FROM
v1data.dbo.IINFO IINFO, v1data.dbo.STAY STAY" & Chr(13)
& "" & Chr(10) & "WHERE (STAY.S_ADATE='" & Format(Range
("Date!B1"), "mm-dd-yy") & "' And STAY.S_ADATE<='" & Format
(Range("Date!B2"), "mm-dd-yy") & "') AND
(STAY.S_STATUS='HIST') A" _
, "ND (STAY.S_NIGHTS=1) AND (IINFO.I_ZIP='00601'
And IINFO.I_ZIP<='99999') AND (IINFO.I_RECID =
STAY.S_IRECID)" & Chr(13) & "" & Chr(10) & "ORDER BY
IINFO.I_ZIP")
.Name = "Query from V1DATA"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default reading variable "from" and "to" ZIP codes


Replace your actual values with variables.

Get a value to your variables BEFORE the line of code that
needs it.

To get the value use someting like ;

FromZip = 0'to re-set the value
ToZip = 0'to re-set the value

FromZip=range("A1").value
ToZip=range("B1").value

and your code that needs the from and to values .....
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default reading variable "from" and "to" ZIP codes

I still receive "compile" errors. I guess I just don't
understand how it all works. Thanks for trying but I
guess I just don't get it. Oh, well.
Dan

-----Original Message-----

Replace your actual values with variables.

Get a value to your variables BEFORE the line of code

that
needs it.

To get the value use someting like ;

FromZip = 0'to re-set the value
ToZip = 0'to re-set the value

FromZip=range("A1").value
ToZip=range("B1").value

and your code that needs the from and to values .....
.

Reply
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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
"Type mismatch" when I try to fill an Array variable with "+" [email protected] Excel Discussion (Misc queries) 1 April 17th 07 01:28 PM
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 AM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM


All times are GMT +1. The time now is 07:46 AM.

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

About Us

"It's about Microsoft Excel"