Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm new to Excel programming & I'm working on a [stock purchase]
spreadsheet trying to compare a column of dates (range named "acquired") to the current date. Any acquired date over 365 days should write a text message saying "long" in the adjacent column range named "holding". Acquired dates less that 365 needs to write "short". Thanks for your help. Joe |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
try this. Of course, modify to suit. Assumes dates in col A
Sub comparedate() For Each c In Range("a1:a3") If c + 365 Now Then c.Offset(, 1) = "Long" If c + 365 < Now Then c.Offset(, 1) = "Short" Next End Sub "Joeyej" wrote in message om... I'm new to Excel programming & I'm working on a [stock purchase] spreadsheet trying to compare a column of dates (range named "acquired") to the current date. Any acquired date over 365 days should write a text message saying "long" in the adjacent column range named "holding". Acquired dates less that 365 needs to write "short". Thanks for your help. Joe |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
if c + 365 is greater than now, then c was acquired less than 365 days ago,
so that should be "short" shouldn't it? Probably should allow for exactly 365 days as well. (although unspecified by the OP). Since Now has a time value, I guess it is unlikely to hit an exactly 365 days situation. -- Regards, Tom Ogilvy Don Guillett wrote in message ... try this. Of course, modify to suit. Assumes dates in col A Sub comparedate() For Each c In Range("a1:a3") If c + 365 Now Then c.Offset(, 1) = "Long" If c + 365 < Now Then c.Offset(, 1) = "Short" Next End Sub "Joeyej" wrote in message om... I'm new to Excel programming & I'm working on a [stock purchase] spreadsheet trying to compare a column of dates (range named "acquired") to the current date. Any acquired date over 365 days should write a text message saying "long" in the adjacent column range named "holding". Acquired dates less that 365 needs to write "short". Thanks for your help. Joe |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Yeah, I guess OP can change to suit.
"Tom Ogilvy" wrote in message ... if c + 365 is greater than now, then c was acquired less than 365 days ago, so that should be "short" shouldn't it? Probably should allow for exactly 365 days as well. (although unspecified by the OP). Since Now has a time value, I guess it is unlikely to hit an exactly 365 days situation. -- Regards, Tom Ogilvy Don Guillett wrote in message ... try this. Of course, modify to suit. Assumes dates in col A Sub comparedate() For Each c In Range("a1:a3") If c + 365 Now Then c.Offset(, 1) = "Long" If c + 365 < Now Then c.Offset(, 1) = "Short" Next End Sub "Joeyej" wrote in message om... I'm new to Excel programming & I'm working on a [stock purchase] spreadsheet trying to compare a column of dates (range named "acquired") to the current date. Any acquired date over 365 days should write a text message saying "long" in the adjacent column range named "holding". Acquired dates less that 365 needs to write "short". Thanks for your help. Joe |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
writing text to different cell after comparing | Excel Worksheet Functions | |||
COUNTIF: 2 criteria: Date Range Column & Text Column | Excel Worksheet Functions | |||
Warning message if one column contains any text and another column is blank | Excel Worksheet Functions | |||
Date format/Writing to a file problem | Excel Discussion (Misc queries) | |||
help with VBA code re comparing cells and generating message with detailed info | Excel Programming |