question about date calculations

ces005

Board Regular
Joined
Mar 13, 2006
Messages
189
Hi,

I have some questions about date logic. Is it safe to do date comparison logic like cell A5's value being < 1/1/06 or do I need to use some date functions?

Also, if I want to subtract some number of weeks from a date (in mm/dd/yy format), should I just take the cell's value (e.g. B5) and subtract 21 from it (if I want to subtract 3 weeks)? I would prefer to not be dependent on excel addons (e.g. date functions), but don't know if my logic would be safe without using date functions. Thanks.

-Eileen
 

Some videos you may like

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

xapie128

Board Regular
Joined
Aug 26, 2006
Messages
82
Internally, Excel stores dates as the number of days since 1/1/1900 (that's the default, but can be changed to 1/1/1904 in the Tools menu). With the default, 1/1/1900 = 1; today, 9/16/2006 = 38,976. You can demonstrate this yourself by entering a date, then formatting the cell to Number format.

So, to answer your first question, it is easiest to compare one cell to another; in your example have 1/1/06 in a cell then compare A5 to the cell that contains 1/1/06.

Regarding your second question, Yes you can do that. If the cell is formatted to display dates, then 9/29/2006 - 21 would result in 9/8/2006.
 

ces005

Board Regular
Joined
Mar 13, 2006
Messages
189
question about readonly cells

Hi,

I have a cell (e.g. C4) where I have a visual basic script to populate the field. How do I make that cell uneditable? I have not made the element an activeX type of control because I am not that sophisticated.

-Eileen
 

ces005

Board Regular
Joined
Mar 13, 2006
Messages
189
Let me change my question.

Cell D3 is a picklist.

How do I set it up so that when a person selects a value from the picklist, this triggers a macro to be called to update some pther cell values (these are computed based on the selected item).
 

ces005

Board Regular
Joined
Mar 13, 2006
Messages
189
oops -- I added my questions to some unrelated question instead of creating a new post. Sorry.
 

Watch MrExcel Video

Forum statistics

Threads
1,112,802
Messages
5,542,585
Members
410,561
Latest member
Sasha Lawrence
Top