VB help

Please can you help with the attached.

If I open the userform and click 'Add' I get an error message. I need to amend the code so that it accepts when nothing has been added to:-

txtHrs1
txtHrs2
txtMins1
txtMins2

 dev3.xls
Kiwi-123Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris BottomleySoftware Quality Lead EngineerCommented:
As a starter for 10 then assuming you want to exit gracefully try:

Chris
Private Sub CommandButton12_Click()
Dim time1 As Date
Dim time2 As Date

    If IsNumeric(txtHrs1.Value) And IsNumeric(txtMins1.Value) And IsNumeric(txtHrs2.Value) And IsNumeric(txtMins2.Value) Then
        time1 = TimeSerial(txtHrs1.Value, txtMins1.Value, 0)
        time2 = TimeSerial(txtHrs2.Value, txtMins2.Value, 0)
        
        With rngStart
            .Offset(, 0).Value = DateValue(Mid(TextBox1.Value, 5))
            .Offset(, 7).Value = DateValue(Mid(TextBox2.Value, 5)) + time1
            .Offset(, 20).Value = DateValue(Mid(TextBox3.Value, 5))
            .Offset(, 21).Value = DateValue(Mid(TextBox4.Value, 5)) + time2
        End With
    End If
    Unload Me

End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.