EXCELGAARD skrev:
Umiddelbart vil jeg foreslå, at man formaterede cellen til at vise ingenting, hvis resultat giver nul, men ellers kan du bruge denne her:
=HVIS(((C5-B5)-D5)=0;"";((C5-B5)-D5))
|
Den går ikke jeg har en VBA kørende der ser således ud:
----------------------------------------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim TimeStr As String
On Error GoTo Endmacro
If Application.Intersect(Target, Range("B1:E1000")) Is Nothing Then
Exit Sub
End If
If Target.Cells.Count > 1 Or Target.Interior.ColorIndex <> -4142 Then
Exit Sub
End If
Application.EnableEvents = False
With Target
If .HasFormula = False Then
Select Case Len(.Value)
Case 1
TimeStr = "00:0" & .Value
Case 2
TimeStr = "00:" & .Value
Case 3
TimeStr = Left(.Value, 1) & ":" & _
Right(.Value, 2)
Case 4
TimeStr = Left(.Value, 2) & ":" & _
Right(.Value, 2)
Case 5
TimeStr = Left(.Value, 1) & ":" & _
Mid(.Value, 2, 2) & ":" & Right(.Value, 2)
Case 6
TimeStr = Left(.Value, 2) & ":" & _
Mid(.Value, 3, 2) & ":" & Right(.Value, 2)
Case Else
Err.Raise 0
End Select
.Value = TimeValue(TimeStr)
Target.Offset(0, 1).Activate
End If
End With
Application.EnableEvents = True
Exit Sub
Endmacro:
Application.EnableEvents = True
End Sub
-----------------------------------------------------------------------------------
Det er for at skrive timetal fra 730 til 7:30 og 1600 til 16:00
Er det muligt at der er en anden løsning på det?