[RESOLVED] calendar/ date reference question
hey all, I'm new here... been searching far and wide for what seems like should be simple. I am a glass blower- not a programmer- but I'm working on learning vba at the moment working on a basic calendar/ to do type application in Excel 2003... on windows xp... and I'm stuck.
So I've found a number of ways to do calendars- but I'm making one that is linear i.e. just goes left to right... any suggestions on that would be appreciated. I did make one but I'm sure there is a better way then I did it.
The main thing I need- why I'm posting- is simply this: I need to reference the year in a date in a cell.... that's all.. just look at the date and say what year it is so that I can then color the different years differently. This isn't that hard is it? I've been able to find different things in code that are close but they're essentially either referencing ONE date (i.e. a start date) or they system date... how do I tell the code to look at any random cell with a date in it and capture the year so as to use that as a reference further??
Thanks for any help!
Re: calendar/ date reference question
Kind of hard to answer without knowing what you mean by 'cell', but
this may help:
Code:
Text1.Text = Now 'assign current date/time to textbox
Debug.Print Year(Text1.Text)
Debug.Print Month(Text1.Text)
Debug.Print Day(Text1.Text)
Debug.Print Hour(Text1.Text)
Debug.Print Minute(Text1.Text)
Debug.Print Second(Text1.Text)
Re: calendar/ date reference question
Well I appreciate the response... but...
Are you serious? You don't know what a CELL is?? Is my question that unclear?
I'm working Excel 2003 on Windows XP using the Visual Basic Editor. Am I on the wrong forum? I thought this was a forum for Visual Basic that I can use.... the program Excel is based on CELLS you gotta know what I'm talking about whether you program or not, most novices have at least USED Excel and understand what a "cell" is.......
Can someone at least just tell me what forum to go to? If you guys don't know what a cell is I'm obviously in the wrong place... that's like a runner not knowing what a shoe is. I'm just using the Visual Basic part of Excel 2003 to program a simple application based in Excel... is this really so alien to you guys??
*Baffled*
Re: calendar/ date reference question
Welcome to VBForums.com :wave:
Quote:
I'm just using the Visual Basic part of Excel 2003 to program a simple application based in Excel
That is VBA not VB6.. :)
Your question should be posted in this forum: Office Development (includes VBA)
I will inform the moderators, so that they will move this Thread....
Quote:
I thought this was a forum for Visual Basic that I can use....
Here, you can post VB5 or VB6 related questions...:)
Re: calendar/ date reference question
Re: calendar/ date reference question
Thread moved to 'Office Development/VBA' forum (note that the "VB Editor" in Office programs is actually VBA rather than VB, so the 'VB6' forum is not really apt)
This may work for you:
Code:
MsgBox Year(Sheet1.Range("A1").Value)
Re: calendar/ date reference question
fantastic! (didn't need the message box.. and worked perfect) thanks for the help, really appreciate it! Now back to the rest of the puzzles to figure out!
Re: calendar/ date reference question
As you now have it sorted out, could you please do us a little favour, and mark the thread as Resolved?
(this saves time reading for those of us who like to answer questions, and also helps those who search to find answers)
You can do it by clicking on "Thread tools" just above the first post in this thread, then "Mark thread resolved". (like various other features of this site, you need JavaScript enabled in your browser for this to work).