Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default max number in cell rest in other cell

I want to enter a number in a cell (any value) and end up with a max. of 8 in
that cell. The remainder to be tranfered to another.
This to create a time-sheet where the normal and overtime hours are
automatically separated
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default max number in cell rest in other cell

Hi

I assume cells are formatted as time and hours are entered as 8:00.

This is an event code and has to be pasted into the code sheet for the
desired sheet. In this example hours are entered in B2:B10 and overtime are
transfered to C2:C10.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim TargetRange As Range

Set TargetRange = Range("B2:B10") ' Change to suit
Set isect = Intersect(Target, TargetRange)

If Not isect Is Nothing Then
If Target.Value TimeValue("08:00:00") Then
mytime = Target.Value
Target.Value = TimeValue("08:00:00")
Target.Offset(0, 1) = mytime - TimeValue("08:00:00")
End If
End If
End Sub

Best regards,
Per

"Harberg" skrev i meddelelsen
...
I want to enter a number in a cell (any value) and end up with a max. of 8
in
that cell. The remainder to be tranfered to another.
This to create a time-sheet where the normal and overtime hours are
automatically separated


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default max number in cell rest in other cell

Hi

I assume cells are formatted as time and hours are entered as 8:00.

This is an event code and has to be pasted into the code sheet for the
desired sheet. In this example hours are entered in B2:B10 and overtime are
transfered to C2:C10.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim TargetRange As Range

Set TargetRange = Range("B2:B10") ' Change to suit
Set isect = Intersect(Target, TargetRange)

If Not isect Is Nothing Then
If Target.Value TimeValue("08:00:00") Then
mytime = Target.Value
Target.Value = TimeValue("08:00:00")
Target.Offset(0, 1) = mytime - TimeValue("08:00:00")
End If
End If
End Sub

Best regards,
Per

"Harberg" skrev i meddelelsen
...
I want to enter a number in a cell (any value) and end up with a max. of 8
in
that cell. The remainder to be tranfered to another.
This to create a time-sheet where the normal and overtime hours are
automatically separated


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
how do you make one cell larger than all the rest George Excel Discussion (Misc queries) 2 May 12th 23 11:44 AM
how to keep the first initial of a name &delete the rest in cell mark Excel Discussion (Misc queries) 2 February 28th 07 05:35 PM
Addind cell together with a rest. Rodger Excel Discussion (Misc queries) 7 February 21st 07 01:32 AM
VBA code to fill rest of cell with dashes (-) mikeburg[_97_] Excel Programming 2 August 18th 06 12:58 AM
Based on one cell criteria to change the rest of that row to a col Rochelle B Excel Discussion (Misc queries) 7 November 13th 05 02:42 AM


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