Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Strange behavior Patrick Simonds Excel Programming 2 November 25th 06 06:26 PM
Strange behavior Ritchie Excel Discussion (Misc queries) 2 September 26th 06 02:21 AM
Strange TAB behavior m davidson Excel Programming 4 May 28th 06 06:09 PM
Strange behavior DeRussie Setting up and Configuration of Excel 4 November 26th 05 05:41 PM
Strange behavior. Wiley Coyote Excel Discussion (Misc queries) 7 October 18th 05 04:35 PM


All times are GMT +1. The time now is 09:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"