Clearing contents not formatting
I posted not too long ago and Gary's Student gave me the following code to
solve my problem:
Private Sub Worksheet_Change(ByVal Target As Range)
Set t = Target
Set b = Range("D:D")
If Intersect(t, b) Is Nothing Then Exit Sub
If t.NumberFormat = "General" Then Exit Sub
Dim s As String
s = t.Value
If Left(s, 1) < "=" Then Exit Sub
Application.EnableEvents = False
t.Clear
t.Formula = s
Application.EnableEvents = True
End Sub
The above code is designed to change the formatting of a cell from 'text' to
'general' if the user inputs an equal sign.
My only concern now is that the t.Clear line wipes out all the other
formatting too. Any suggestions on how to keep the background color and
indentation but swap out the text for general?
|