microsoft access vba courses - recognising dates
Microsoft Office Training verified by visa - mastercard securecode about microsoft training company london ukadd this page to your favourites/bookmarksAdd to favourites
view a printable version of this pagePrintable version
email this page to somebodyEmail this page
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft VBA Training and help » microsoft access vba courses - Recognising Dates

microsoft access vba courses - Recognising Dates

The UK's most regular instructor-led training courses.
Training information: microsoft access vba courses · Excel london

resolvedResolved · Low Priority · Version Standard

Recognising Dates

James has attended:
Excel VBA course

by - delegate James [7 posts] (2008 Jan 22 Tue, 14:49) replyReply

Hi Carlos,

I am currently writing a macro that, in one section of it, needs to search through a list of dates (row by row assigning each date to a variable and comparing using SelectCase). Unfortunately the list is an export from a piece of software that creates date cells in the format
" 12/31/2007"

The problem occurs when the cell shows
" 01/02/2008" to " 01/12/2008"
excel seems to treat this as dd/mm/yyyy and then back to mm/dd/yyyy when the middle value is more than 12.

I then use the line:
DateValue = ActiveCell.Value
to assign the data in this cell to the variable "DateValue".

Is there anything I can add to this line to assign the variable in a uniform manner?

Regardss,

James

RE: Recognising Dates

by - delegate James [7 posts] (2008 Jan 22 Tue, 15:18) replyReply

I have just found one solution for this - changing my computers regional setting to US!
Is this the only fix or is there an easier one?

RE: Recognising Dates

by - trainer Carlos gold contributer[360 posts] (2008 Feb 6 Wed, 17:05) replyReply

Hi James

Received the e-mail but there was just an image of the regional options dialog box attached.

Could you send the workbook?

I'm busy training the next few days but as soon as I get some time I'll look at it.

Carlos

RE: Recognising Dates

by - trainer Carlos gold contributer[360 posts] (2008 Feb 6 Wed, 10:13) replyReply

James

First Don't use DateValue as a variable name. This is a Date Function in Excel

I created 2 variables :

1. MyDate - This holds the date being compared to
2. ImportDate - This will hold each of the imported dates to compare

Now compare the two dates eg:

MyRow = 1

ImportDate = Cells(MyRow,1).Value

If MyDate = ImportDate then

<Do code>

MyRow = MyRow + 1

End If

This can loop through all the dates

By doing this the computer saves the imported date as UK.

Hope this helps. If not please send me the Weorkbook with your code and I'll see what I can do

Regards

Carlos

RE: Recognising Dates

by - delegate James [7 posts] (2008 Feb 6 Wed, 12:38) replyReply

Carlos,

I have a similar code setup for the loop (just with a couple more variables - firstdate, seconddate etc) with a select case instead of an IF.

I have tried changing DateValue to ImportDate but this doesn't work.
Can you send me your email address so that I can attach the workbook? I can't seem to attach files to this reply...

Regards,

James

RE: Recognising Dates

by - trainer Carlos gold contributer[360 posts] (2008 Feb 6 Wed, 14:52) replyReply

Hi James

Send the workbook to

info at microsofttraining.net

Attention Carlos

and my collegues will forward it to me

Regards

Carlos


Related articles

· What Is Microsoft Excel VBA and How Can It Help You Work Smarter?
· Company Roles in Visual Basic Training

Vba tip:

Empty The Clipboard with CutCopyMode

After each Copy/Paste operation in VBA, you should use the following line of code to empty the clipboard. This ensures that the computer memory doesn't overload:

ActiveSheet.Paste
Application.CutCopyMode = False

View all VBA hints and tips

Institute of IT Training - Accredited Training Provider Institute of IT Training - Accredited Training Provider Prodigy Platinum Learning Partner Microsoft Office Specialist Authorised Testing Centre

Microsoft Registered Partner
microsoft office
ms office project server

Association of Computer Trainers Valid HTML 4.01 Transitional
Valid CSS Markup

secure online payments - visa - mastercard

Mini sitemap. These are the main areas of our web site. Full sitemap.

Training by application Main information pages See also

Access courses
DreamWeaver courses
Excel courses
MS Project courses
Outlook courses
PowerPoint courses
VBA courses
Word courses
(more...)

Public scheduled courses
On-site training
Closed company courses

Microsoft Office training
Pricing and availability
Training schedule
Training venues

Access training
Dreamweaver training
Excel training
MS Project training
PowerPoint training

London Computer Training
Computer Training London

Microsoft Access training
Microsoft Excel training
Microsoft Project training
Microsoft Outlook training
Microsoft Powerpoint training
Microsoft Word training

Time Management Course London

Interested in Access training? Please see the following pages:
microsoft access courses · microsoft training access course
microsoft+access+training · access courses in london

Training Information
AddThis Social Bookmark Button What's this?
Add to Del.icio.us Add to Facebook Add to Digg Add to Reddit Add to Google Add to Yahoo Add to Diigo Add to Mr. Wong Add to Linkarena Add to Power Oldie Add to Folkd Add to Jumptags Add to Upchuckr Add to Simpy Add to StumbleUpon Add to Slashdot Add to Netscape Add to Furl Add to Spurl Add to Blinklist Add to Blogmarks Add to Technorati Add to Newsvine Add to Blinkbits Add to Ma.Gnolia Add to Smarking Add to Netvouz