Hi everyone,
I would like to be able to:
- use Selection.Interior.ColorIndex on several columns but only once every line.
- if 1 cell (B5) on the line (5) has already been "colored" (selected) and I select an other cell (D5) one the same line then the the first cell (B5) go back to no color no target.
- avoid using a "snitch" loop that is constantly checking a statement (to keep the macro light and running smoothly) but more in a way that the macro allows you to color the one cell you need and reset other cells on the line (if this make any sense).
here's what I am using now
This is an example from a larger macro I use. Target 5 help me for calculations.
I've been searching on the forum and online ways to meet my "user" requirements but I couldn't find anything helpful.
I guess it's kinda specific ... Please bear with me I've never used this function and I am fairly new to VBA macros.
Please let me know if I need to add more info or if my explanation isn't clear.
Any info or comment will help me improve :D
Thank you for your time.
I would like to be able to:
- use Selection.Interior.ColorIndex on several columns but only once every line.
- if 1 cell (B5) on the line (5) has already been "colored" (selected) and I select an other cell (D5) one the same line then the the first cell (B5) go back to no color no target.
- avoid using a "snitch" loop that is constantly checking a statement (to keep the macro light and running smoothly) but more in a way that the macro allows you to color the one cell you need and reset other cells on the line (if this make any sense).
here's what I am using now
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
'First table
'column a
If Not Intersect(Selection, Range("a1:a20")) Is Nothing Then
With Target
If Selection.Interior.ColorIndex = xlNone Then
Selection.Interior.ColorIndex = 4
Target = 5
Else
Selection.Interior.ColorIndex = xlNone
Target = ""
End If
End With
End If
'column b
If Not Intersect(Selection, Range("b1:b20")) Is Nothing Then
With Target
If Selection.Interior.ColorIndex = xlNone Then
Selection.Interior.ColorIndex = 8
Target = 5
Else
Target = ""
Selection.Interior.ColorIndex = xlNone
End If
End With
End If
'column c
If Not Intersect(Selection, Range("c1:c20")) Is Nothing Then
With Target
If Selection.Interior.ColorIndex = xlNone Then
Selection.Interior.ColorIndex = 6
Target = 5
Else
Target = ""
Selection.Interior.ColorIndex = xlNone
End If
End With
End If
'column d
If Not Intersect(Selection, Range("d1:d20")) Is Nothing Then
With Target
If Selection.Interior.ColorIndex = xlNone Then
Selection.Interior.ColorIndex = 23
Target = 5
Else
Target = ""
Selection.Interior.ColorIndex = xlNone
End If
End With
End If
This is an example from a larger macro I use. Target 5 help me for calculations.
I've been searching on the forum and online ways to meet my "user" requirements but I couldn't find anything helpful.
I guess it's kinda specific ... Please bear with me I've never used this function and I am fairly new to VBA macros.
Please let me know if I need to add more info or if my explanation isn't clear.
Any info or comment will help me improve :D
Thank you for your time.