|
-
Feb 26th, 2006, 06:57 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] American Date Format - vba
Hi Guys,
Need a way to programatically/dyanmically shown today date in american format:-
i.e 2/28/2006
Must be formated as per bold above?
Can anyone advise?
Boris
-
Feb 26th, 2006, 07:09 AM
#2
Thread Starter
Hyperactive Member
Re: American Date Format - vba - excel
Any anyideas chaps ? I am trying to do this for excel vba.
Boris
-
Feb 26th, 2006, 08:58 AM
#3
Lively Member
Re: American Date Format - vba
Code:
Me.datebox.Value = Format(Now(), "mm/dd/yyyy")
-
Feb 26th, 2006, 12:35 PM
#4
Thread Starter
Hyperactive Member
Re: American Date Format - vba
Thanks for trying to help but its doesn't work basiaclly I'm trying to offset the date against column A which already contains random data. It doesn't like it for some reason, could you help me debug.
VB Code:
Sub Dates()
Dim filelength As Long
filelength = ActiveSheet.UsedRange.Rows.Count
Range("a1").Activate 'Activates a2
For i = 1 To filelength
ActiveCell.Offset(0, 1).formula = Me.datebox.Value = Format(Now(), "mm/dd/yyyy")
ActiveCell.Offset(1, 0).Activate
Next i
End Sub
Thanks Boris.
-
Feb 26th, 2006, 12:54 PM
#5
Re: American Date Format - vba
You cant have 2 equal signs on the same line.
ActiveCell.Offset(0, 1).formula = Me.datebox.Value = Format(Now(), "mm/dd/yyyy")
Whats the offset needing to be? the cell value plus a date value?
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 
-
Feb 26th, 2006, 01:06 PM
#6
Thread Starter
Hyperactive Member
Re: American Date Format - vba
Basically I have random data in column a (any length).
Just need the american date format in column B offseted against the used range in column A.
It need to fixed in column B and dynamic (live) each time the programe is run:-
i.e 28/2/2006
Must be exactly that format , no times etc.
Thanks Very much, hope you can help
Best Regards,
Boris
-
Feb 26th, 2006, 01:10 PM
#7
Re: American Date Format - vba
Something like this but you may want to trap for the appropriate range first so it doesnt try to format invalid data from another column.
VB Code:
= Format(ActiveCell, "mm/dd/yyyy")
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 
-
Feb 26th, 2006, 01:25 PM
#8
Thread Starter
Hyperactive Member
Re: American Date Format - vba
Hi M8,
Nearly there I suppose but not quite the desired result, this may explain what I need , column A contains "BOB" (OR ANY RANDOM DATA not related). Column contains today date live (american style) as above.
This is the output when I run the program:-
cOLUMNA cOLUM B
BOB 12/31/1899
BOB 01/01/00
BOB 02/01/00
BOB 02/01/00
BOB 02/01/00
BOB 02/01/00
BOB 02/01/00
BOB 02/01/00
BOB 02/01/00
This is what I have:
VB Code:
[B]Sub Dates()
Dim filelength As Long
filelength = ActiveSheet.UsedRange.Rows.Count
Range("a1").Activate 'Activates a2
For i = 1 To filelength
ActiveCell.Offset(0, 1).formula = Format(ActiveCell, "mm/dd/yyyy")
ActiveCell.Offset(1, 0).Activate
Next i
End Sub[/B]
-
Feb 26th, 2006, 02:13 PM
#9
Re: American Date Format - vba
I dontsee where your changing the cell in your loop. It needs either to be referenced directly or each cell needs activating so the ActiveCell will change. Right now its always taking from the save value.
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 
-
Feb 26th, 2006, 03:40 PM
#10
Thread Starter
Hyperactive Member
Re: American Date Format - vba
This part of code is changing the row each time.
VB Code:
ActiveCell.Offset(1, 0).Activate
Please bear with me , I'm a junior at coding:-
I assume you get the "just" of what I'm trying to achieve, appreciate if you help finish what I'm trying to do.
VB Code:
[I]filelength = ActiveSheet.UsedRange.Rows.Count[/I]
The above part of code is needed making it it only available to the used range which is what Iwant "integligence in knowing where to stop". I assume I need to use a loop.
If you can thinking of a smarter way then great m8. Appreciate if you can add some comments where neccessary - so can understand and learn.
Look forward to your response.
Boris
-
Feb 26th, 2006, 07:12 PM
#11
Re: American Date Format - vba
Ok, lets re-think this. What is the date column (B) supposed to increment by? Increment by a day, a month, or a year?
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 
-
Feb 27th, 2006, 03:50 AM
#12
Thread Starter
Hyperactive Member
Re: American Date Format - vba
Hi it only meant to increment to today date live each time the program is run. Therefore it has to be dynamic.
so today will be:-
2/27/2006
tommorrow will be
2/28/2006
Must be exactly this format.
Hope this clarifies,
B
-
Feb 27th, 2006, 03:58 AM
#13
Re: American Date Format - vba
VB Code:
ActiveCell.Offset(0, 1).formula = Format(Date, "mm/dd/yyyy")
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 
-
Feb 27th, 2006, 04:30 PM
#14
Thread Starter
Hyperactive Member
Re: American Date Format - vba
Thanks , you truly are a genius.
You've savedme a sleeples night.
-
Feb 27th, 2006, 04:43 PM
#15
Re: American Date Format - vba
Glad someone is getting sleep as I am working on a sql db issue with only 3 hours sleep so far. 
Thanks for the props 
Ps, dont forget to Resolve your thread.
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 
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
|