Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Month and year programmatically in a cell?

Can we have the months of the year statically while having the current year
in the same cell, somehow? In other words, a formula that puts each month
of the year in 12 different cells then next to each month a code for the
year, like =today, say, so whenever we print out that sheet, we'll always
have January yyyy to December yyyy with yyyy being the current year? I'm
sure there must be a way, just can't figure out how.

Thanks. :oD


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Month and year programmatically in a cell?


Hi, I don't think you need a formula. Would simply changing the cell
format work? If so, just go to Format Cells Number Custom and
enter "mmmm yyyy" (w/o quotes)

If you're looking for VBA, there's several ways to do that i.e.
******
With .Cells(1, 1)
'.Value = DATE
'.FormulaR1C1 = "=TODAY()" 'inserts formula for
today
..Formula = .Value 'takes the formula above &
converts to value
'.NumberFormat = "ddd, * d mmm yy" 'returns Fri,
25 Nov 05 (*=justified alignment)
..NumberFormat = "mmmm yyyy" 'returns November 2005
..NumberFormat = "mmm yyyy" 'returns Nov 2005
End With

HTH


--
AH·C
------------------------------------------------------------------------
AH·C's Profile: http://www.excelforum.com/member.php...o&userid=29108
View this thread: http://www.excelforum.com/showthread...hreadid=488295

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Month and year programmatically in a cell?


I forgot to mention that if you use the formated cell route, you can
simply type "Jan" (w/o quote) in the first cell, XL will figure out
what you mean. Then you just grab the right-bottom corner, and drag to
the left for 11 cells and have XL auto-fill the series for you.


--
AH·C
------------------------------------------------------------------------
AH·C's Profile: http://www.excelforum.com/member.php...o&userid=29108
View this thread: http://www.excelforum.com/showthread...hreadid=488295

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default Month and year programmatically in a cell?

On Fri, 25 Nov 2005 19:02:19 -0600, AH·C
wrote:


I forgot to mention that if you use the formated cell route, you can
simply type "Jan" (w/o quote) in the first cell, XL will figure out
what you mean. Then you just grab the right-bottom corner, and drag to
the left for 11 cells and have XL auto-fill the series for you.


Hmmm, yes, that part I have though text month is fully printed out.
Problem is with getting a year programmatically so that it doesn't
have to be typed in each time. So far this sheet requires no user
input for the structure at all. Once the user puts in a birthdate and
the name, all the rest automatically updates meaning that each time
the user prints out this sheet, all the dates are current to the time
the sheet is printed out. The date of printout is put in one of the
cells as a sort of footer to the page, so all's clear.

That's why I figured some sort of formula typed into the cell would
work best. In cell A2, we'd have the printout say "January 2005" for
the page printed out this year and "January 2006" if we printed it out
next year, while D2 says "February 2005" this year and "February 2006"
next year without the user ever doing anything to each of these cells.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Month and year programmatically in a cell?


Aha, then what you want is the following in each "mmmm yyyy" cell:

January 2005
=DATE(YEAR(TODAY()),*1*,1)

February 2005
=DATE(YEAR(TODAY()),*2*,1)

.......

December 2005
=DATE(YEAR(TODAY()),*12*,1)


--
AH·C
------------------------------------------------------------------------
AH·C's Profile: http://www.excelforum.com/member.php...o&userid=29108
View this thread: http://www.excelforum.com/showthread...hreadid=488295



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default Month and year programmatically in a cell?

On Sat, 26 Nov 2005 15:58:42 -0600, AH·C
wrote:


Aha, then what you want is the following in each "mmmm yyyy" cell:

January 2005
=DATE(YEAR(TODAY()),*1*,1)

February 2005
=DATE(YEAR(TODAY()),*2*,1)

......

December 2005
=DATE(YEAR(TODAY()),*12*,1)


YES, that's it, something like this! Sorry for delay in getting back
to this thread. I and all my colleagues are working a lot of overtime
with elections looming just past New Year's so it's been a tough
couple of weeks. I just got home from putting in nearly a full day
today.

Yes, this is exactly the type of thing I was looking for so that I
wouldn't have to re-do the sheet as it's already very fine-tuned.
This didn't actually work because I'm getting a "the formula you typed
contains an error", but I'm sure we're definitely on the right track.
The concept is exactly what I need.

How can I narrow down what the error might be, do you know? XL2K
isn't giving me any clues.

Thanks so much! :oD

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default Month and year programmatically in a cell?

On Fri, 25 Nov 2005 18:58:03 -0600, AH·C
wrote:


Hi, I don't think you need a formula. Would simply changing the cell
format work? If so, just go to Format Cells Number Custom and
enter "mmmm yyyy" (w/o quotes)


Okay, that's easy enough and what I usu. do for other cases, but this
case is different. Without any user input at all, ever, how do you
get in one cell only for each below:

- cell A2 = "January 2005" this yr, "January 2006" next year, while
- cell D2 = February 2005 this yr, Februaruy 2006 next yr, etc.,
- cell A9 = March 2005 this yr, March 2006 next yr, etc.,

etc., etc., all again without any user input. I know that
programmatically this must be able to be done, just how to do this.
Surely this can't be beyond E2K! All the other dates on the page also
require no input, they do automatically update as there are many cells
in the rows in between the month cells and the DATEIF function then
easy to implement. It's just the fact that without going in to
completely re-do those month/year cells to split them, a horrendous
task, there is no way other than with user input to fix these cells.
The sheet is protected and those cells are locked, however, and we'd
all like to keep it that way <g.

If you're looking for VBA, there's several ways to do that i.e.
******
With .Cells(1, 1)
'.Value = DATE
'.FormulaR1C1 = "=TODAY()" 'inserts formula for
today
Formula = .Value 'takes the formula above &
converts to value
'.NumberFormat = "ddd, * d mmm yy" 'returns Fri,
25 Nov 05 (*=justified alignment)
NumberFormat = "mmmm yyyy" 'returns November 2005
NumberFormat = "mmm yyyy" 'returns Nov 2005
End With


Does one have to launch this macro, though? Is there no way to just
put a formula into a cell?

HTH


Thanks. Getting closer, I think (hope). <g

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Month and year programmatically in a cell?


You may have lost me. Did my formula help or are you still looking for
a solution? Once my formula is in place, there is no need for user
input.

Now if you're talking about going thru all of your files and amending
the changes, then you should try recording a macro for the changes,
inserting a line to unprotect the sheet prior to making the changes,
and another to protect again and place this macro in your Personal.xls.
That way everytime you open an old file, you can just run it.

Push come to shove, you may have to upload a sample file.

HTH

Andy


--
AH·C
------------------------------------------------------------------------
AH·C's Profile: http://www.excelforum.com/member.php...o&userid=29108
View this thread: http://www.excelforum.com/showthread...hreadid=488295

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default Month and year programmatically in a cell?

On Sun, 27 Nov 2005 19:15:37 -0600, AH·C
wrote:


You may have lost me. Did my formula help or are you still looking for
a solution? Once my formula is in place, there is no need for user
input.


Yes, it did, thanks! Your messages came after the fact. There was a
bit of a delay (my ISP may have been having troubles, or the troubles
were my end.

Now if you're talking about going thru all of your files and amending
the changes, then you should try recording a macro for the changes,


Fortunately, it's only 12 cells that are involved in a spreadsheet
that is already exquisitely fine-tuned and one that I didn't want to
mess up by adding a column in order to go the route I normally do with
something like this. When we have a cell for the month and for the
year, that's easy. In this case I would have the months printed out
in one of the cells for each date, and the year as TODAY formatted
just to show the year.

inserting a line to unprotect the sheet prior to making the changes,
and another to protect again and place this macro in your Personal.xls.
That way everytime you open an old file, you can just run it.


Cool. I'll keep that in mind for future if this type of case comes
up.

Push come to shove, you may have to upload a sample file.


<g Thank you, you're very kind. As I just posted in the other msg
in this thread, your formula is exactly what I'm looking for it's just
that there was a problem with an error. I'm sure it'll be easy enough
to figure out.

HTH


Thanks, it will! :oD

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combine month day and year from separate columns in to one cell Thanks, JH Excel Discussion (Misc queries) 4 April 3rd 23 04:42 PM
Tell me which "season" (Month/Day through Month/Day) a date(Month/Day/Year) falls in (any year)??? misscrf Excel Discussion (Misc queries) 1 December 14th 07 02:59 PM
trying to get day/month/year froamt while user enters year only RADIOOZ New Users to Excel 3 June 7th 06 05:30 AM
how can I highlight a cell if it meets year and month criteria Clyde Excel Worksheet Functions 2 May 11th 06 02:24 PM
Dates of a Day for a month & year cell formulas mikeburg Excel Discussion (Misc queries) 2 December 29th 05 10:14 PM


All times are GMT +1. The time now is 01:57 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"