LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default If statement question


The code below is designed to change a number input, such as 1425 to 14:25.
Is there anything I can do prevent the code from running if the number is
already properly inputted?


Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim e

ActiveSheet.Unprotect

On Error GoTo ErrorHandler

If Not Application.Intersect(Target, Range("E3:E8000")) Is Nothing Then

If ActiveCell < "" Then GoTo ErrorHandler

e = Left(Format(Target.Value, "0000"), 4)
Application.EnableEvents = False
Target.Formula = Left(e, 2) & ":" & Right(e, 2)

End If


Application.EnableEvents = True

If ActiveCell = ":" Then GoTo ClearCell

Exit Sub

ClearCell:

Selection.ClearContents

Exit Sub

ErrorHandler:


Exit Sub:

End Sub


 
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
IF - And - Then Statement question MayJuneJuly Excel Worksheet Functions 4 September 19th 08 04:00 PM
IF Statement question peg84 Excel Discussion (Misc queries) 3 February 4th 08 10:19 PM
IF statement question [email protected] Excel Worksheet Functions 2 July 24th 06 04:20 PM
IF Statement Question Scott Excel Worksheet Functions 15 June 14th 05 07:56 PM
IF Statement question gryfon Excel Worksheet Functions 6 May 4th 05 09:21 AM


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

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

About Us

"It's about Microsoft Excel"