Strange formatting behavior

  • Thread starter Patrick Simonds
  • Start date
P

Patrick Simonds

Can anyone tell me why/how the code below causes the cell format in the
column to the right to change from a number format to a text format. I
should expand on this a little. If I enter a number say in cell F8 and use
the arrow button to go down to cell F9, everything is fine. By fine I mean
that the : is placed between the numbers I enter and the format of the
cell to the right does not change from a Number format to a Text format.

But if I enter a number in cell F8 and use the right arrow to move to the
next cell to the right, the : is placed between the numbers but the
cell format to the right changes to a text format. All cells in column F are
formatted for Text, all cell in column G are formatted for Numbers.




If Not Application.Intersect(Target, Range("F3:F8000")) Is Nothing Then

If ActiveCell < "" Then GoTo ErrorHandler

With ActiveCell
.NumberFormat = "@"
e = Left(Format(Target.Value, "0000"), 4)
Application.EnableEvents = False
Target.Formula = Left(e, 2) & ":" & Right(e, 2)
End With
End If
 
P

Patrick Simonds

Solved my problem by eliminating:

With ActiveCell
.NumberFormat = "@" and
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top