LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Assign a Date Variable within VBA Q

Bingo , that worked

Thanks to all the Guy's who helped with this problem, it will allow me to
apply a variable to a whole series of ideas I have and safe time

Thanks again

"Chip Pearson" wrote in message
...
Get rid of the closing parenthesis after Value.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"John" wrote in message
...
Bob tried your format code but its getting a compile error
"Expected end of
statement" error at the ","


"Bob Phillips" wrote in
message
...
John,

Try formatting the date

FromDate = Format(Workbooks("Pull Gross Sales for 2005
Financial

Year.xls").Worksheets("Sheet2").Range("A1").Value) ,"yyyy-mm-dd")

--

HTH

RP
(remove nothere from the email address if mailing direct)


"John" wrote in message
...
I have a few questions the answers of which might explain
why my code is
not
working. First an outline of what I'm trying to do

Extract information from an MS Access database and pull in
to Excel.

I've
recorded the Macro and everything works great, except that
the 'from'

date
with regards to Sales information is hard coded and thus
inflexible, in
that
I wouldn't allow other users, who have to get this
information, dabble
with
the code itself

I've been told through this group that I should set a
variable and then
call
this through the relevant code line. When the information is
extracted

the
hard code for the relevant Sales date is in the following
format
"YYYY-MM-DD
hh:mm:ss". Now the cell which I want to reference my cell
against

visually
is formated DD/MM/YY

The error message I'm getting is a SQL debug on the line
below, but from
reading other usergroups it could be a formatting problem

.Refresh BackgroundQuery:=False



My relevant code is then set as follows


Dim FromDate As String
FromDate = Workbooks("Pull Gross Sales for 2005
Financial
Year.xls").Worksheets("Sheet2").Range("A1").Value


"WHERE (tblStoreTotals.SalesDate={ts '" & FromDate & "'})"


Now my questions

1. Does it matter that the source cell (Sheet2 A1) is typed
in as

DD/MM/YY
with no hh:mm:ss. I'm in Europe so thats how we type in
dates

2. Do I have to format a linked cell to A1 say B1 as
YYYY-MM-DD hh:mm:ss

3. Someone must have got a Data Import module working with a
variable
reference, any examples would be appreciated













 
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
Assign value to a variable name Gnarlodious Excel Discussion (Misc queries) 2 August 20th 06 07:10 AM
Assign value to variable rroach Excel Discussion (Misc queries) 1 July 13th 05 05:24 AM
Variable VB to assign new sheet name Kevin M Excel Worksheet Functions 0 June 17th 05 12:15 AM
assign variable Tim Excel Programming 10 October 1st 04 07:33 PM
VBA routine to assign first name only to a variable fitful_thought Excel Programming 6 August 3rd 04 01:39 PM


All times are GMT +1. The time now is 10:53 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"