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
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

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.
 

Forum statistics

Threads
1,141,429
Messages
5,706,402
Members
421,447
Latest member
arthuro2021

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top