Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Updating a cell based on contents of two other cells

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Updating a cell based on contents of two other cells


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,073
Default Updating a cell based on contents of two other cells

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Updating a cell based on contents of two other cells

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
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
How do I add a cell based on another cells contents? Debbie Excel Discussion (Misc queries) 1 December 22nd 06 06:33 PM
Delete/clear a cell based on another cells contents jademaddy Excel Programming 2 May 19th 05 06:15 PM
Modify Row & Cell Contents based upon Cells Values bpat1434 Excel Worksheet Functions 0 November 7th 04 03:31 PM
Modify Row & Cell Contents based upon Cells Values bpat1434 Excel Worksheet Functions 1 November 7th 04 12:43 PM
Modify Row & Cell Contents based upon Cells Values bpat1434 Excel Worksheet Functions 1 November 6th 04 05:17 PM


All times are GMT +1. The time now is 01:31 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"