Meningen er den skal løbe gennem kolonne S og checke om der er tal over 8! Er der det skal den komme op med en boks, med en besked.
koden ser således ud:
Private Sub Worksheet_Calculate() If Intersect(Target, Range("S:S")) Is Nothing Then Exit Sub If Target.Value = ">8" Then MsgBox "You entered to many hrs. for travelling", vbExclamation End If End Sub
Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, Range("F1:F100")) Is Nothing Then Exit Sub If Target.Value = "Transport Hotel/Site - Site/Hotel" Then MsgBox "You have chosen Transport Hotel/Site - Site/Hotel, When working Offshore you are only entitled, to book 12,00 hours a day in total", vbExclamation If Target.Value = "Travelling Onshore (home/site - site/home - site/site)" Then MsgBox "You have chosen Travelling Onshore (home/site - site/home - site/site), When working Offshore you are only entitled, to book 8,00 hours per travel in total", vbExclamation If Target.Value = "Work time Onshore" Then MsgBox "You have chosen Work time Onshore, Please consider, to give detailed description and with an NCR number if applicable", vbExclamation If Target.Value = "Indirect time on site Offshore" Then MsgBox "You have chosen Indirect time on site Offshore, When Indirect time, check your garanteed hours for this day, your total ammount of hours are not to exceed the guranteed hours", vbExclamation If Target.Value = "Indirect time on site Onshore" Then MsgBox "You have chosen Indirect time on site Offshore, When Indirect time, check your garanteed hours for this day, your total ammount of hours are not to exceed the guranteed hours", vbExclamation If Target.Value = "Indirect time off site Onshore (abroad)" Then MsgBox "You have chosen Indirect time on site Onshore (abroad), When Indirect time, check your garanteed hours for this day, your total ammount of hours are not to exceed the guranteed hours", vbExclamation If Target.Value = "Indirect time off site Onshore (home)" Then MsgBox "You have chosen Indirect time on site Onshore (home), When Indirect time, check your garanteed hours while at Home, your total ammount of hours are not to exceed the guranteed hours", vbExclamation If Target.Value = "Transport Offshore" Then MsgBox "You have chosen Transport Offshore, Offshore Transport hours, are not to exceed 12 hours per day", vbExclamation
Private Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Target, Range("F1:F100")) Is Nothing Then If Target.Value = "Transport Hotel/Site - Site/Hotel" Then MsgBox "You have chosen Transport Hotel/Site - Site/Hotel, When working Offshore you are only entitled, to book 12,00 hours a day in total", vbExclamation If Target.Value = "Travelling Onshore (home/site - site/home - site/site)" Then MsgBox "You have chosen Travelling Onshore (home/site - site/home - site/site), When working Offshore you are only entitled, to book 8,00 hours per travel in total", vbExclamation If Target.Value = "Work time Onshore" Then MsgBox "You have chosen Work time Onshore, Please consider, to give detailed description and with an NCR number if applicable", vbExclamation If Target.Value = "Indirect time on site Offshore" Then MsgBox "You have chosen Indirect time on site Offshore, When Indirect time, check your garanteed hours for this day, your total ammount of hours are not to exceed the guranteed hours", vbExclamation If Target.Value = "Indirect time on site Onshore" Then MsgBox "You have chosen Indirect time on site Offshore, When Indirect time, check your garanteed hours for this day, your total ammount of hours are not to exceed the guranteed hours", vbExclamation If Target.Value = "Indirect time off site Onshore (abroad)" Then MsgBox "You have chosen Indirect time on site Onshore (abroad), When Indirect time, check your garanteed hours for this day, your total ammount of hours are not to exceed the guranteed hours", vbExclamation If Target.Value = "Indirect time off site Onshore (home)" Then MsgBox "You have chosen Indirect time on site Onshore (home), When Indirect time, check your garanteed hours while at Home, your total ammount of hours are not to exceed the guranteed hours", vbExclamation If Target.Value = "Transport Offshore" Then MsgBox "You have chosen Transport Offshore, Offshore Transport hours, are not to exceed 12 hours per day", vbExclamation End If
If Intersect(Target, Range("S1:S1000")) Is Nothing Then Exit Sub If Target.Value > 8 Then MsgBox "You entered to many hrs. for travelling", vbExclamation ActiveCell.Offset(-1, 0).Select Target = "" End If
End Sub
Jeg anvender Excel 2016 DK. Hvad anvender DU ? HUSK TILBAGEMELDING !!!
Er der en venlig sjæl, som kan se hvad der er galt, med koden herunder, der er lavet lidt om på det så det er nemmere at rette i "beskederne" til brugeren, men det ser ikke ud til at virke desværre.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim feedback As String
Const msg As String = "You have chosen - "
Const msg_Guaranteed As String = "your total ammount of hours are not to exceed the guranteed hour"
Const msg1 As String = "When working Offshore you are only entitled, to book 12,00 hours a day in total"
Const msg2 As String = "When working Offshore you are only entitled, to book 8,00 hours per travel in total"
Const msg3 As String = "Please consider, to give detailed description and with an NCR number if applicable"
Const msg4 As String = "When Indirect time, check your garanteed hours for this day, " & msg_Guaranteed
Const msg5 As String = "When Indirect time, check your garanteed hours for this day, " & msg_Guaranteed
Const msg6 As String = "When Indirect time, check your garanteed hours for this day, " & msg_Guaranteed
Const msg7 As String = "When Indirect time, check your garanteed hours while at Home, " & msg_Guaranteed
Const msg8 As String = "Offshore Transport hours, are not to exceed 12,00 hours per day"
On Error GoTo wsc_exit
Application.EnableEvents = False
If Intersect(Target, Me.Range("F6:F123,M6:M123,N6:N123")) Is Nothing Then Exit Sub
If Me.Cells(Target.Row, "S").Value > 8 Then
Select Case Me.Cells(Target.Row, "F").Value
Case "Transport Hotel/Site - Site/Hotel": feedback = msg1
Case "Travelling Onshore (home/site - site/home - site/site)": feedback = msg2
Case "Work time Onshore": feedback = msg3
Case "Indirect time on site Offshore": feedback = msg4
Case "Indirect time on site Onshore": feedback = msg5
Case "Indirect time off site Onshore (abroad)": feedback = msg6
Case "Indirect time off site Onshore (home)": feedback = msg7
Case "Transport Offshore": feedback = msg8
End Select
If feedback <> "" Then
MsgBox msg & vbNewLine & Me.Cells(Target.Row, "F").Value & vbNewLine & vbNewLine & feedback, vbExclamation
Me.Cells(Target.Row, "M").Resize(, 2).Value = ""
End If
End If
wsc_exit:
Application.EnableEvents = True
End Sub
Du kan ikke oprette nye emner i dette forum Du kan ikke besvare beskeder i dette forum Du kan ikke slette dine beskeder i dette forum Du kan ikke redigere dine beskeder i dette forum Du kan ikke oprette afstemninger i dette forum Du kan ikke stemme i dette forum