|
-
May 17th, 2006, 06:11 AM
#1
Thread Starter
Junior Member
Excel date problem
Am using a command button and autofilter to only see things with todays date.
VB Code:
Sub TodaysFault()
Sheets("Database").Select
Selection.AutoFilter Field:=3, Criteria1:=Format(Now, "mm/dd/yyyy"), Operator:=xlAnd
End Sub
I've had a browse around the forums and found the
VB Code:
Criteria1:=Format(Now, "mm/dd/yyyy")
part. Got a feeling this is where I'm going wrong. Basically the Criteria1:= needs to be todays date and then once the macro has run autofilter only shows todays date of parts that I have in my sheet.
-
May 17th, 2006, 06:26 AM
#2
Thread Starter
Junior Member
Re: Excel date problem
Should I have done this in VBA?
-
May 17th, 2006, 06:30 AM
#3
Thread Starter
Junior Member
Re: Excel date problem
Just messing around with it would it have anything to do with the date format?
-
May 17th, 2006, 07:04 AM
#4
Thread Starter
Junior Member
Re: Excel date problem
Just need to know the code for todays date, tried google and going through the old forum posts and have nothing. Any help will be appreciated!
-
May 18th, 2006, 08:22 AM
#5
Thread Starter
Junior Member
Re: Excel date problem
Anyone else got any idea?
-
May 18th, 2006, 09:07 AM
#6
Re: Excel date problem
Today's date is
VB Code:
Format(Now, "mm/dd/yyyy")
Are you doing this in VB6 or Excel VBA?
-
May 18th, 2006, 09:11 AM
#7
Re: Excel date problem
Criteria1:=Format(Now, "mm/dd/yyyy")
Seems you already had your answer in your question. Seems this is Excel -VBA 'cause of the "Sheets("Database").Select"
-
May 23rd, 2006, 03:31 AM
#8
Thread Starter
Junior Member
Re: Excel date problem
Excel VBA, still having no luck
-
May 23rd, 2006, 04:13 AM
#9
Frenzied Member
Re: Excel date problem
Have you got your days and months the correct way around for your data ?
i.e. would this work instead :
VB Code:
Format(Now, "dd/mm/yyyy")
-
May 23rd, 2006, 04:22 AM
#10
Re: Excel date problem
Moved
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
May 23rd, 2006, 06:35 AM
#11
Thread Starter
Junior Member
Re: Excel date problem
Would it have anything to do with the format of the cell or anything like that? The date is in the correct format as far as I can see, dd/mm/yyyy and this is how I have it in the code.
-
May 23rd, 2006, 06:38 AM
#12
Frenzied Member
Re: Excel date problem
What ARE the cells formatted as ?
-
May 23rd, 2006, 10:00 AM
#13
Re: Excel date problem
I think you either
a) need to turn the filter off then back on again
or
b) refresh/requery the autofilter
Either way you'd need to do call that as the workbook/sheet opens.
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|