View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Patrick Molloy Patrick Molloy is offline
external usenet poster
 
Posts: 1,049
Default input the date range for update Pivot table

i'd assumed that you already had the VBA code for getting the data out of
the sql server

"Jason" wrote in message
...
Hi Patrick,

Where can I place the following statement ?
macro?

Best regards,
Jason

"Patrick Molloy" wrote:

you'll have some SQL which includes the parameters?
so we have two place holders (aka tokens) in the textual SQL query string
eg

sSQL =
"SELECT {...fields etc } FROM { blah } WHERE ( MYDATE '%date1%' AND
MYDATE < '%date2%' )"

its the WHERE clause you need look
change MYDATE for the appropriate field from your database table

if your dates are in Ranges A1 abd B1 then the next line should be

sSQL = REPLACE(sSQL,"%date1%",Range("A1").Value)
sSQL = REPLACE(sSQL,"%date2%",Range("B1").Value)



"Jason" wrote in message
...
Dear all,

Could I create two cell for input the date range and update pivot table
(data from sql server) according the date range?

Thanks,
Jason