PC Review


Reply
Thread Tools Rate Thread

Date Problem in VBA

 
 
=?Utf-8?B?am9obmI=?=
Guest
Posts: n/a
 
      29th Oct 2007
Hi All
I'm importing data from an Access query in to an Excel pivot table and as I
many of these imports to do I set the following constants in a standatd
module.
Private Const YearStart As Date = #1/4/2007#
Private Const YearEnd As Date = #31/3/2008#

The Dates I need are 1st April 2007 to 31st March 2008 however the date
#1/4/2007# is changed by Excel to #4/1/2007# so that the pivottable show for
the 1st january 2007. I've chacked the Windows XP Regional setting for the
date and are dd/mm/yyyy which is ok. Is there another setting somewhere? Any
suggesstions as to why the date #1/4/2007# is being changed?

TIA
johnb
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      29th Oct 2007
VBA is pretty USA centric.

I'd try the USA settings: #4/1/2007# (for April 1, 2007)

Personally, I'd try to remove any ambiguity:

Private YearStart as Date
....

Later
yearstart = dateserial(2007,4,1)

===
I have no idea how Access queries work, though.

johnb wrote:
>
> Hi All
> I'm importing data from an Access query in to an Excel pivot table and as I
> many of these imports to do I set the following constants in a standatd
> module.
> Private Const YearStart As Date = #1/4/2007#
> Private Const YearEnd As Date = #31/3/2008#
>
> The Dates I need are 1st April 2007 to 31st March 2008 however the date
> #1/4/2007# is changed by Excel to #4/1/2007# so that the pivottable show for
> the 1st january 2007. I've chacked the Windows XP Regional setting for the
> date and are dd/mm/yyyy which is ok. Is there another setting somewhere? Any
> suggesstions as to why the date #1/4/2007# is being changed?
>
> TIA
> johnb


--

Dave Peterson
 
Reply With Quote
 
=?Utf-8?B?am9obmI=?=
Guest
Posts: n/a
 
      29th Oct 2007
Hi Dave

Yeah. good point to define it later I shall try it!
regards
johnb

"Dave Peterson" wrote:

> VBA is pretty USA centric.
>
> I'd try the USA settings: #4/1/2007# (for April 1, 2007)
>
> Personally, I'd try to remove any ambiguity:
>
> Private YearStart as Date
> ....
>
> Later
> yearstart = dateserial(2007,4,1)
>
> ===
> I have no idea how Access queries work, though.
>
> johnb wrote:
> >
> > Hi All
> > I'm importing data from an Access query in to an Excel pivot table and as I
> > many of these imports to do I set the following constants in a standatd
> > module.
> > Private Const YearStart As Date = #1/4/2007#
> > Private Const YearEnd As Date = #31/3/2008#
> >
> > The Dates I need are 1st April 2007 to 31st March 2008 however the date
> > #1/4/2007# is changed by Excel to #4/1/2007# so that the pivottable show for
> > the 1st january 2007. I've chacked the Windows XP Regional setting for the
> > date and are dd/mm/yyyy which is ok. Is there another setting somewhere? Any
> > suggesstions as to why the date #1/4/2007# is being changed?
> >
> > TIA
> > johnb

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
=?Utf-8?B?am9obmI=?=
Guest
Posts: n/a
 
      29th Oct 2007
I'm using a UK date format eg dd/mm/yyyy and I use a Yearstart as a Const coz
it's referred to many time in the module. So I need to force a UK date format
and my brains on strike. Ant ideas?
regards

johnb

"johnb" wrote:

> Hi Dave
>
> Yeah. good point to define it later I shall try it!
> regards
> johnb
>
> "Dave Peterson" wrote:
>
> > VBA is pretty USA centric.
> >
> > I'd try the USA settings: #4/1/2007# (for April 1, 2007)
> >
> > Personally, I'd try to remove any ambiguity:
> >
> > Private YearStart as Date
> > ....
> >
> > Later
> > yearstart = dateserial(2007,4,1)
> >
> > ===
> > I have no idea how Access queries work, though.
> >
> > johnb wrote:
> > >
> > > Hi All
> > > I'm importing data from an Access query in to an Excel pivot table and as I
> > > many of these imports to do I set the following constants in a standatd
> > > module.
> > > Private Const YearStart As Date = #1/4/2007#
> > > Private Const YearEnd As Date = #31/3/2008#
> > >
> > > The Dates I need are 1st April 2007 to 31st March 2008 however the date
> > > #1/4/2007# is changed by Excel to #4/1/2007# so that the pivottable show for
> > > the 1st january 2007. I've chacked the Windows XP Regional setting for the
> > > date and are dd/mm/yyyy which is ok. Is there another setting somewhere? Any
> > > suggesstions as to why the date #1/4/2007# is being changed?
> > >
> > > TIA
> > > johnb

> >
> > --
> >
> > Dave Peterson
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
::: Date Comparison Problem or Date Formula or Date Macro ::: infojacques@gmail.com Microsoft Excel Discussion 3 13th Jul 2007 10:08 AM
[Newbie UK Date problem] Ways atround this UK date format localisation/SQLselection issue? DC Microsoft ASP .NET 5 1st Jul 2005 10:35 PM
[Newbie UK Date problem] Ways atround this UK date format localisation/SQLselection issue? DC Microsoft C# .NET 5 1st Jul 2005 10:35 PM
Formatting Problem-Highlighting a cell when date has expired past current date alancyoung Microsoft Excel Misc 1 19th Feb 2004 05:14 PM
Date Range: Between [Start Date] and [End Date] problem KL Microsoft Access Queries 4 16th Dec 2003 02:14 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:24 PM.