R
Rob Hargreaves
Hi I have found a variation on some code and it works fine when i set the
targ values below as numbers.
I cant get it to refer to the cells which are provided as named ranges.
You can see below my efforts in the code below.
Please can someone give me the correct code to make it work
Thanks for your help.
Rob
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Error
Dim icolour As Integer
Dim targ1 As Long
Dim targ2 As Long
Dim targ3 As Long
Dim targ4 As Long
Dim targ5 As Long
Dim targ6 As Long
Dim targ7 As Long
Dim targ8 As Long
targ1 = ''''
targ2 = ''''
targ3 = Range(ActiveWorkbook.Names("NaburnMLSSTrig2a")).Value
targ4 = Range(ActiveWorkbook.Names("NaburnMLSSTrig2b")).Value
targ5 = NaburnMLSSTrig3a
targ6 = NaburnMLSSTrig3b
targ7 = ''''
targ8 = ''''
'EXAMPLE FROM POST
'Range(ActiveWorkbook.Names("NaburnMLSSTrig1a")).Value
If Not Intersect(Target, Range("Y:AB")) Is Nothing Then
Select Case Target
Case targ1 To targ2
icolour = 45
Case targ3 To targ4
icolour = 3
Case targ5 To targ6
icolour = 45
Case targ7 To targ8
icolour = 3
Case Else
ActiveCell.Interior.ColorIndex = xlColorIndexNone
End Select
Target.Interior.ColorIndex = icolour
End If
targ values below as numbers.
I cant get it to refer to the cells which are provided as named ranges.
You can see below my efforts in the code below.
Please can someone give me the correct code to make it work
Thanks for your help.
Rob
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Error
Dim icolour As Integer
Dim targ1 As Long
Dim targ2 As Long
Dim targ3 As Long
Dim targ4 As Long
Dim targ5 As Long
Dim targ6 As Long
Dim targ7 As Long
Dim targ8 As Long
targ1 = ''''
targ2 = ''''
targ3 = Range(ActiveWorkbook.Names("NaburnMLSSTrig2a")).Value
targ4 = Range(ActiveWorkbook.Names("NaburnMLSSTrig2b")).Value
targ5 = NaburnMLSSTrig3a
targ6 = NaburnMLSSTrig3b
targ7 = ''''
targ8 = ''''
'EXAMPLE FROM POST
'Range(ActiveWorkbook.Names("NaburnMLSSTrig1a")).Value
If Not Intersect(Target, Range("Y:AB")) Is Nothing Then
Select Case Target
Case targ1 To targ2
icolour = 45
Case targ3 To targ4
icolour = 3
Case targ5 To targ6
icolour = 45
Case targ7 To targ8
icolour = 3
Case Else
ActiveCell.Interior.ColorIndex = xlColorIndexNone
End Select
Target.Interior.ColorIndex = icolour
End If