I get this code to work now, but i need it to run for several cells.
I my example it only work for cell Q8, but it also need to be for:
Q9-Q16 + Q19-Q27 + Q30-Q38 + Q41-Q49 + Q52-Q60 + Q63-Q71 + Q74-Q82
How can i make references in my code for that?
Also the blue marked references should raise according to the above extra references.
I know, this is basic vba coding, but i'm new with this.
Thanks in advance.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim formula As String
If Not Application.Intersect(Target, Range("P8")) Is Nothing Then
If Target.Value = "Vagtudkald" Then
Range("Q8").Value = ""
Range("Q8").Select
With Selection.Interior
.Color = RGB(255, 255, 0)
End With
With Selection.Validation
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=Time24"
End With
Else
Range("Q8").FormulaLocal = "=IF(OR(P8="""";R7="""");"""";R7)"
Range("Q8").Select
With Selection.Interior
.Color = RGB(217, 217, 217)
End With
With Selection.Validation
.Delete
End With
End If
End If
End Sub
I my example it only work for cell Q8, but it also need to be for:
Q9-Q16 + Q19-Q27 + Q30-Q38 + Q41-Q49 + Q52-Q60 + Q63-Q71 + Q74-Q82
How can i make references in my code for that?
Also the blue marked references should raise according to the above extra references.
I know, this is basic vba coding, but i'm new with this.
Thanks in advance.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim formula As String
If Not Application.Intersect(Target, Range("P8")) Is Nothing Then
If Target.Value = "Vagtudkald" Then
Range("Q8").Value = ""
Range("Q8").Select
With Selection.Interior
.Color = RGB(255, 255, 0)
End With
With Selection.Validation
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=Time24"
End With
Else
Range("Q8").FormulaLocal = "=IF(OR(P8="""";R7="""");"""";R7)"
Range("Q8").Select
With Selection.Interior
.Color = RGB(217, 217, 217)
End With
With Selection.Validation
.Delete
End With
End If
End If
End Sub