Want to calculate the appointment date and deappointment date?

R

Raja

Hi All,

Greeting for the day.

I have date 12-Jul-09 in cell A1

If i enter "APPT" In cell B2 then C2 have to show 11-Jul-09 (D-1)

If it is "DEPPT" IN Cell B2 then C2 have to show 13-Jul-09 (D+1)

Note : This APPT and DEPPT will be mixed together ill just copy past
them into a Sheet when i do that i need a VBA program to show these day
automatically.

Any help would be appreicated.

Regards,

Raj
 
J

JLGWhiz

Copy and paste this to your worksheet code module.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target = Range("B2") Then
Range("C2").NumberFormat = "dd-mmm-yy"
If Target.Value = "APPT" Then
Range("C2") = Date - 1
ElseIf Target.Value = "DEPPT" Then
Range("C2") = Date + 1
End If
End If
End Sub
 
J

JLGWhiz

I should have read your post more closely. You want to base the change on
the value in A1, I believe.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target = Range("B2") Then
Range("C2").NumberFormat = "dd-mmm-yy"
If Target.Value = "APPT" Then
Range("C2") = Range("A1").Value - 1
ElseIf Target.Value = "DEPPT" Then
Range("C2") = Range("A1").Value + 1
End If
End If
End Sub
 
R

Raja

JLGWhiz;413560 said:
Copy and paste this to your worksheet code module.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target = Range("B2") Then
Range("C2").NumberFormat = "dd-mmm-yy"
If Target.Value = "APPT" Then
Range("C2") = Date - 1
ElseIf Target.Value = "DEPPT" Then
Range("C2") = Date + 1
End If
End If
End Sub




Code Cage Forums
(http://www.thecodecage.com/forumz/showthread.php?t=115205)



Thanks but its not working.

please advice...

Raj
 
R

Raja

Hi JLGWhiz,

Your code working only for the B2 in the example i had mentioned it fo
the understanding.Ok to explain you further say ill always copy past
the date in A:A and "APPT" OR DEAPPT" IN B:B and i need those outcome i
C:C always.
Sorry for not explaining them earlier.

Many thanks,

Raj
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top