Strange formatting behavior
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 |
Strange formatting behavior
Solved my problem by eliminating:
With ActiveCell .NumberFormat = "@" and End With "Patrick Simonds" wrote in message ... 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 |
All times are GMT +1. The time now is 09:16 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com