Thanks Antonio... we're getting close!
I have a previous macro (mentioned before) to turn text 'd100' into a '<downarrow>100' in red text, and 'u100' into '<uparrow>100' in green text. red for down, green for up.
The macro for that is:
If Target.Count > 1 Then Exit Sub
If Intersect(Target, [R6:AT96]) Is Nothing Then Exit Sub
If Not Target Like "[ud]*" Then Target.font.Name = "Arial": Target.font.Color = vbBlack: Exit Sub
Application.EnableEvents = False
Target.font.Name = "Arial"
With Target.Characters(1, 1)
.font.Name = "Marlett"
.Text = IIf(.Text = "u", "t", "u")
Target.font.Color = IIf(.Text = "u", vbRed, vbGreen)
End With
Application.EnableEvents = True
So,
Including your macro into this Worksheet_Change, it now doesnt change the value 'd100' to '<downarrow>100' in red in the new cell R6, and vice versa in green..
Here's the whole macro so you can test it your side :
Private Sub Worksheet_Change(ByVal Target As Range)
Dim lastCol As Integer, myRow As Long
If Target.Cells.Count = 1 And Target.Column = 16 Then
myRow = Target.Row
Application.EnableEvents = False
With ThisWorkbook.ActiveSheet
lastCol = .Cells(myRow, Columns.Count).End(xlToLeft).Column
If lastCol >= 18 Then
.Cells(myRow, 18).Resize(, lastCol - 17).Copy .Cells(myRow, 19)
End If
End With
Target.Offset(, 2) = Target
Target = ""
Application.EnableEvents = True
End If
If Target.Count > 1 Then Exit Sub
If Intersect(Target, [R6:AJ43]) Is Nothing Then Exit Sub
If Not Target Like "[ud]*" Then Target.font.Name = "Arial": Target.font.Color = vbBlack: Exit Sub
Application.EnableEvents = False
Target.font.Name = "Arial"
With Target.Characters(1, 1)
.font.Name = "Marlett"
.Text = IIf(.Text = "u", "t", "u")
Target.font.Color = IIf(.Text = "u", vbRed, vbGreen)
End With
Application.EnableEvents = True
End Sub
As you can see, your macro is working, value 'u100' from P6 gets inserted into R6 when pressing enter, but it doesn't change to an '<uparrow>100' in green text anymore. A workaround is to just double clicking R6, and hit enter. This executes it, and it changes.
Is there a way to automate this though, so it does everything at once??
That should be all then!
Thanks so much for you help on this....
Bookmarks