Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
RudeRam
 
Posts: n/a
Default Cell Formatting w/following Macro


I am using the following macro to speed the input of times into a ws,
the problem I have run across is the time go into every even numbered
row, and each work assigment goes in the odd row, when I enter the work
assigments in the odd rows I get a colon inserted in the text.

I have tried formatting the cells to text only but that doesn't work, I
have tried to just put in the even numbered cells i.e. B6:C6, B8:C8 etc
but I get a range is to long error in VBA,

Thanks for any help

Rick

Private Sub Worksheet_Change(ByVal Target As Range)
Dim UserInput, r&
Application.EnableEvents = False
If Not Intersect(Target, [B:C,E:F,H:I,K:L,N:O,Q:R,T:U]) Is Nothing
Then
If Not Selection.Cells.Count = 1 Then
Application.Undo
Application.EnableEvents = True
Exit Sub
End If
If Target.Value < 1 Then
UserInput = Format(Int(Target.Value * 24) * 100 + ((Target.Value * 24)
- Int(Target.Value * 24)) * 60, "0000")
Else
UserInput = Format(Target.Value, "0000")
End If
If Len(UserInput) 1 Then
Target = Left(UserInput, Len(UserInput) - 2) & ":" & Right(UserInput,
2)
End If
r = Target.Row
If Cells(r, 9) = "" Or Cells(r, 10) = "" Then
Cells(r, 11).ClearContents
Else
Cells(r, 4).FormulaR1C1 = "=MOD(RC[-1]-RC[-2],1)"
End If
End If
Application.EnableEvents = True
End Sub


--
RudeRam


------------------------------------------------------------------------
RudeRam's Profile: http://www.excelforum.com/member.php...fo&userid=8818
View this thread: http://www.excelforum.com/showthread...hreadid=555575

  #2   Report Post  
Posted to microsoft.public.excel.misc
Bernie Deitrick
 
Posts: n/a
Default Cell Formatting w/following Macro

Rick,

Use this as the first line of your macro:

If Target.Row Mod 2 = 1 Then Exit Sub

HTH,
Bernie
MS Excel MVP


"RudeRam" wrote in message
...

I am using the following macro to speed the input of times into a ws,
the problem I have run across is the time go into every even numbered
row, and each work assigment goes in the odd row, when I enter the work
assigments in the odd rows I get a colon inserted in the text.

I have tried formatting the cells to text only but that doesn't work, I
have tried to just put in the even numbered cells i.e. B6:C6, B8:C8 etc
but I get a range is to long error in VBA,

Thanks for any help

Rick

Private Sub Worksheet_Change(ByVal Target As Range)
Dim UserInput, r&
Application.EnableEvents = False
If Not Intersect(Target, [B:C,E:F,H:I,K:L,N:O,Q:R,T:U]) Is Nothing
Then
If Not Selection.Cells.Count = 1 Then
Application.Undo
Application.EnableEvents = True
Exit Sub
End If
If Target.Value < 1 Then
UserInput = Format(Int(Target.Value * 24) * 100 + ((Target.Value * 24)
- Int(Target.Value * 24)) * 60, "0000")
Else
UserInput = Format(Target.Value, "0000")
End If
If Len(UserInput) 1 Then
Target = Left(UserInput, Len(UserInput) - 2) & ":" & Right(UserInput,
2)
End If
r = Target.Row
If Cells(r, 9) = "" Or Cells(r, 10) = "" Then
Cells(r, 11).ClearContents
Else
Cells(r, 4).FormulaR1C1 = "=MOD(RC[-1]-RC[-2],1)"
End If
End If
Application.EnableEvents = True
End Sub


--
RudeRam


------------------------------------------------------------------------
RudeRam's Profile: http://www.excelforum.com/member.php...fo&userid=8818
View this thread: http://www.excelforum.com/showthread...hreadid=555575



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
Compiling macro based on cell values simonsmith Excel Discussion (Misc queries) 1 May 16th 06 08:31 PM
Conditional Format as a MACRO Gunjani Excel Worksheet Functions 3 March 29th 06 05:22 PM
Deferring conditional formatting? Pheasant Plucker® Excel Discussion (Misc queries) 14 March 17th 06 08:17 PM
Urgent date/scheduling calc needed jct Excel Worksheet Functions 3 February 24th 06 01:36 AM
Transfer Cell Formatting for linked cells Scott Excel Discussion (Misc queries) 2 November 23rd 05 11:04 PM


All times are GMT +1. The time now is 05:59 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"