View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default IF statement but in code

Try the below

If Trim(Target.Offset(0,-1)) = "" Then
Target.Offset(0, 2).AddComment UserName() & " - AoS due by: " & _
Format(Target.Value + 14, "dd mmm")
Else
Target.Offset(0, 2).AddComment UserName() & " - AoS due by: " & _
Format(Target.Value + Target.Offset(0,-1).Value , "dd mmm")
End If

If this post helps click Yes
---------------
Jacob Skaria


"Jock" wrote:

Hi,
I have code which will add a comment box two cells to the right whenever a
date is placed in column "N".
There is text within this comment box which is added by the code and takes
the date from "N" and adds 14 (days).
On occasion, I will need to overide the 14 days with a number from column
"M" which is manually input into that cell.

So, in eccence, I need someting like:
If (M5="",N5+14,N5+M5) but in the following code:

Dim strTemp As Date
'adds a comment box to cells in column P when date is entered in N
On Error Resume Next
If Not Intersect(Target, Me.Range("N4:N9999")) Is Nothing Then
With Target
If .Value < "" Then
Application.EnableEvents = False
strTemp = Target.Offset(0, 3).Text
Target.Offset(0, 2).AddComment UserName() & " - AoS due by: " &
Format(Target.Value + 14, "dd mmm")
Target.Offset(0, 2).Comment.Shape.TextFrame.AutoSize = True
'On Error GoTo 0
Application.EnableEvents = True
End If
End With
End If


Any ideas???
--
Traa Dy Liooar

Jock