S
Simon Bailey
Hi,
Hope someone can help - I am getting very frustrated!
My problem is in 2 parts:
1) I have the following code on a worksheet (found from a previous
question), that updates the cell/text colour when you enter a
specific letter.
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Select Case Target.Value
Case "A"
Target.Interior.ColorIndex = 15
Target.Font.ColorIndex = 15
Case "V"
Target.Interior.ColorIndex = 36
Target.Font.ColorIndex = 36
Case "F"
Target.Interior.ColorIndex = 44
Target.Font.ColorIndex = 44
Case "D"
Target.Interior.ColorIndex = 6
Target.Font.ColorIndex = 6
Case "G"
Target.Interior.ColorIndex = 32
Target.Font.ColorIndex = 32
Case "N"
Target.Interior.ColorIndex = 37
Target.Font.ColorIndex = 37
End Select
End Sub
This works fine, until I select a range of cells and delete the data:
1) I get a "Runtime error '13' - Type mismatch error" and 2) the
cells stop the colour. How do I 1) change the code to solve the
error? 2) revert the cell to it's previous colour (not always the
same)?
2) I have another worksheet linked to the first and replicate the
information (alot of other info on sheet as well). I have got the
Formula to give me the correct letter as a result, but the colour
does not update, unless I do F2 enter on each individual cell (not
practical). I believe the issue is around the Worksheet_change
command, as I am not really changing the worksheet the data is just
refreshing - therefore what in my code needs to change? The above
issues also applies to this problem.
Many thanks, in advance, for any help - but please go easy, my VB
knowledge is limited
Simon
Hope someone can help - I am getting very frustrated!
My problem is in 2 parts:
1) I have the following code on a worksheet (found from a previous
question), that updates the cell/text colour when you enter a
specific letter.
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Select Case Target.Value
Case "A"
Target.Interior.ColorIndex = 15
Target.Font.ColorIndex = 15
Case "V"
Target.Interior.ColorIndex = 36
Target.Font.ColorIndex = 36
Case "F"
Target.Interior.ColorIndex = 44
Target.Font.ColorIndex = 44
Case "D"
Target.Interior.ColorIndex = 6
Target.Font.ColorIndex = 6
Case "G"
Target.Interior.ColorIndex = 32
Target.Font.ColorIndex = 32
Case "N"
Target.Interior.ColorIndex = 37
Target.Font.ColorIndex = 37
End Select
End Sub
This works fine, until I select a range of cells and delete the data:
1) I get a "Runtime error '13' - Type mismatch error" and 2) the
cells stop the colour. How do I 1) change the code to solve the
error? 2) revert the cell to it's previous colour (not always the
same)?
2) I have another worksheet linked to the first and replicate the
information (alot of other info on sheet as well). I have got the
Formula to give me the correct letter as a result, but the colour
does not update, unless I do F2 enter on each individual cell (not
practical). I believe the issue is around the Worksheet_change
command, as I am not really changing the worksheet the data is just
refreshing - therefore what in my code needs to change? The above
issues also applies to this problem.
Many thanks, in advance, for any help - but please go easy, my VB
knowledge is limited
Simon