D
Damil4real
Two fantastic people were kind enough to provide me these two codes
below, and now I'm trying to see if I can expand it to include other
columns and data in a worksheet.
Code 1:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myC As Range
If Intersect(Target, Range("P")) Is Nothing Then Exit Sub
Application.EnableEvents = False
For Each myC In Intersect(Target, Range("P"))
Range("Q" & myC.Row).Value = Date - Target.Value
Next myC
Application.EnableEvents = True
End Sub
Code 2:
Private Sub Worksheet_Change(ByVal Target As Range)
'Don't do anything unless needed
If Intersect(Range("P"), Target) Is Nothing _
Or Target.Count > 1 Then Exit Sub
'Don't do anything if cell is blank
If Target.Value = "" Then Exit Sub
Application.EnableEvents = False
'Create value:
Target.Offset(0, 1).FormulaR1C1 = _
"=IF(RC[-1]="""","""",TODAY()-RC[-1])"
Application.EnableEvents = True
End Sub
-------------------------------------------------
How can I expand the worksheet selection code above in order to
incorporate the functions that I have below? I'll greatly appreciate
your assistance.
Data in both column A to F are manually entered.
Data in column J populates when you enter data in column E.
Data in column K populates when you enter data in column F.
Data in columns L, M & O populates when you enter data in column E &
F.
The three Sheet Tabs are named: (Overview, M.A., Vacation Trip).
All of these data are in the Overview tab.
Excel code in each cell of each column are as follows.
Code in column F is:
=IF(ISNA(VLOOKUP($H7,'Vacation Trip'!$A$2:$C$4573,2,FALSE))=TRUE,
0,VLOOKUP($H7,'Vacation Trip'!$A$2:$C$4573,2,FALSE))
Code in column J is:
=IF(ISNA(VLOOKUP($G7,M.A.!$A$2:$E$5708,4,FALSE))=TRUE,0,VLOOKUP
($G7,M.A.!$A$2:$E$5708,4,FALSE))
Code in column L is:
=J7-K7
Code in column M is:
=IF(ISNA(VLOOKUP($G7,M.A.!$A$2:$E$5392,5,FALSE))=TRUE,0,VLOOKUP
($G7,M.A.!$A$2:$E$5392,5,FALSE))-IF(ISNA(VLOOKUP($H7,'Vacation Trip'!
$A
$2:$C$4573,3,FALSE))=TRUE,0,VLOOKUP($H7,'Vacation Trip'!$A$2:$C
$4573,3,FALSE))
Constant data in column N is 1 (no code)
Code in column O is:
=M7*N7
Data in column P is manually entered (DATE format)
Code in column Q is:
=IF(P7<>"",=TODAY()-P7,"")
The two codes above that I'm trying to expand was initially created
to
have column Q populate its code based off of the date entered in
column P…, but now I'm trying to see if I can expand this code to
incorporate the other codes & columns above.
Thanks a great deal for your assistance!!!!!
Thanks!
below, and now I'm trying to see if I can expand it to include other
columns and data in a worksheet.
Code 1:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myC As Range
If Intersect(Target, Range("P")) Is Nothing Then Exit Sub
Application.EnableEvents = False
For Each myC In Intersect(Target, Range("P"))
Range("Q" & myC.Row).Value = Date - Target.Value
Next myC
Application.EnableEvents = True
End Sub
Code 2:
Private Sub Worksheet_Change(ByVal Target As Range)
'Don't do anything unless needed
If Intersect(Range("P"), Target) Is Nothing _
Or Target.Count > 1 Then Exit Sub
'Don't do anything if cell is blank
If Target.Value = "" Then Exit Sub
Application.EnableEvents = False
'Create value:
Target.Offset(0, 1).FormulaR1C1 = _
"=IF(RC[-1]="""","""",TODAY()-RC[-1])"
Application.EnableEvents = True
End Sub
-------------------------------------------------
How can I expand the worksheet selection code above in order to
incorporate the functions that I have below? I'll greatly appreciate
your assistance.
Data in both column A to F are manually entered.
Data in column J populates when you enter data in column E.
Data in column K populates when you enter data in column F.
Data in columns L, M & O populates when you enter data in column E &
F.
The three Sheet Tabs are named: (Overview, M.A., Vacation Trip).
All of these data are in the Overview tab.
Excel code in each cell of each column are as follows.
Code in column F is:
=IF(ISNA(VLOOKUP($H7,'Vacation Trip'!$A$2:$C$4573,2,FALSE))=TRUE,
0,VLOOKUP($H7,'Vacation Trip'!$A$2:$C$4573,2,FALSE))
Code in column J is:
=IF(ISNA(VLOOKUP($G7,M.A.!$A$2:$E$5708,4,FALSE))=TRUE,0,VLOOKUP
($G7,M.A.!$A$2:$E$5708,4,FALSE))
Code in column L is:
=J7-K7
Code in column M is:
=IF(ISNA(VLOOKUP($G7,M.A.!$A$2:$E$5392,5,FALSE))=TRUE,0,VLOOKUP
($G7,M.A.!$A$2:$E$5392,5,FALSE))-IF(ISNA(VLOOKUP($H7,'Vacation Trip'!
$A
$2:$C$4573,3,FALSE))=TRUE,0,VLOOKUP($H7,'Vacation Trip'!$A$2:$C
$4573,3,FALSE))
Constant data in column N is 1 (no code)
Code in column O is:
=M7*N7
Data in column P is manually entered (DATE format)
Code in column Q is:
=IF(P7<>"",=TODAY()-P7,"")
The two codes above that I'm trying to expand was initially created
to
have column Q populate its code based off of the date entered in
column P…, but now I'm trying to see if I can expand this code to
incorporate the other codes & columns above.
Thanks a great deal for your assistance!!!!!
Thanks!