Macro code to reference a cell for a date parameter when pulling data

J

JAlvarez

I have this code:


& "AND (matter.mmatter Like '" & Sheets("Parameters").Range("C17").Valu
& "')" & Chr(13) & "" & Chr(10) & "AND (timecard.ttk Like '"
Sheets("Parameters").Range("C19").Value & "')" & Chr(13) & "" & Chr(10
& "AND (timecard.tworkdt>={ts '2012-01-01 00:00:00'}) " & Chr(13) & ""
Chr(10) & "AND (timecard.tworkdt<={ts '2012-01-31" _
, " 00:00:00'})")

It works fine, but I want the date part:

"AND (timecard.tworkdt>={ts '2012-01-01 00:00:00'}) "

to reference a cell in the worksheer (ie D5) instead of been fixed.
ANy help will be appreciated.
Thanks
 
A

Auric__

JAlvarez said:
I have this code:


& "AND (matter.mmatter Like '" & Sheets("Parameters").Range("C17").Value
& "')" & Chr(13) & "" & Chr(10) & "AND (timecard.ttk Like '" &
Sheets("Parameters").Range("C19").Value & "')" & Chr(13) & "" & Chr(10)
& "AND (timecard.tworkdt>={ts '2012-01-01 00:00:00'}) " & Chr(13) & "" &
Chr(10) & "AND (timecard.tworkdt<={ts '2012-01-31" _
, " 00:00:00'})")

It works fine, but I want the date part:

"AND (timecard.tworkdt>={ts '2012-01-01 00:00:00'}) "

to reference a cell in the worksheer (ie D5) instead of been fixed.
ANy help will be appreciated.

Try something like this:
"AND (timecard.tworkdt>=" & Range("D5").Value
or:
"AND (timecard.tworkdt>=" & Cells(5, 4).Value
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top