Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I need a routine that will add so many days to another cell depending on the
contents of a particular cell. I have a cell (J2) that has W (for weekly), B (for Bi Weekly), or M (for Monthly). When cell N2 (Last date) is updated with a new date, I need to add 7 days if J2 has a W, or 14 days if J2 has a B or 30 Days id J2 contains an M. and put the new date in cell L2 (the new due date), Cell L2 contains the Due Date.... the one that needs to be updated after the calculation Cell J2 contains the info to base the calculation on W, B, or M Cell N2 contains the old due date that is used to start the calculation Any help is greatly appreciated. Jonco |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() This should be what you need just paste it into the Sheet code module, I must tell you that the letter that appears in J2 must be upper case if you want it to be lower case just change it in the code, i'm sure someone will have a smarter way for you in this forum. Regards, Simon Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Range("J2").Text = "W" Then Range("L2") = Range("N2").Value + 7 ElseIf Range("J2").Text = "B" Then Range("L2") = Range("N2").Value + 14 ElseIf Range("J2").Text = "M" Then Range("L2") = Range("N2").Value + 30 End If End Sub -- Simon Lloyd ------------------------------------------------------------------------ Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708 View this thread: http://www.excelforum.com/showthread...hreadid=557955 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi jonco,
Here's another way, but I don't know that it is smarter. Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$N$2" Or Target.Address = "$J$2" Then Dim iDays As Byte Application.EnableEvents = False On Error GoTo ERRORHANDLER Select Case UCase(Range("J2").Value) Case "W" iDays = 7 Case "B" iDays = 14 Case "M" iDays = 30 End Select Range("L2").Value = Range("N2").Value + iDays Application.EnableEvents = True Exit Sub ERRORHANDLER: Application.EnableEvents = True End If End Sub Ken Johnson |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks guys, I'll give these a try.
Jonco "jonco" wrote in message .com... I need a routine that will add so many days to another cell depending on the contents of a particular cell. I have a cell (J2) that has W (for weekly), B (for Bi Weekly), or M (for Monthly). When cell N2 (Last date) is updated with a new date, I need to add 7 days if J2 has a W, or 14 days if J2 has a B or 30 Days id J2 contains an M. and put the new date in cell L2 (the new due date), Cell L2 contains the Due Date.... the one that needs to be updated after the calculation Cell J2 contains the info to base the calculation on W, B, or M Cell N2 contains the old due date that is used to start the calculation Any help is greatly appreciated. Jonco |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I add a cell based on another cells contents? | Excel Discussion (Misc queries) | |||
Delete/clear a cell based on another cells contents | Excel Programming | |||
Modify Row & Cell Contents based upon Cells Values | Excel Worksheet Functions | |||
Modify Row & Cell Contents based upon Cells Values | Excel Worksheet Functions | |||
Modify Row & Cell Contents based upon Cells Values | Excel Worksheet Functions |