Hi All
I have created a (time sheet) userform with 7 textboxes each representing a day of the week (Monday – Sunday). I have a further 4 textboxes for the Daily Rate, Gross Pay, Tax Paid and final ‘Net Pay’.
I have restricted entry in the 7 textboxes to 1 or 0. - 1 for a day worked or 0 for a day not worked.
I would like (on the change event) as the user enters 1 - the Gross, Tax and the Net Pay textboxes are automatically updated.
This requires each day worked to be multiplied by the ‘Daily Rate’ (txtRate).
I have managed to achieve the above for the first textbox (Monday) but have not been able to do so for the remaining 6 textboxes (Tuesday – Sunday).
I’ve looked on line and seen others have had similar issues but none of the solutions have worked for my purpose. If anyone has a solution the working code I’ve used in textbox 1(txtDay1) is:
Private Sub txtDay1_Change()
Me. txtDay 1.MaxLength = 1
On Error Resume Next
If Me.txtCIS.Value = "No" Or Me.txtCIS.Value = "Pending" Then
Me.txtGross.Value = Sum * Me.txtRate.Value
Me.txtTax.Value = Me.txtGross * 30 / 100
Me.txtNet.value = Me.txtGross.Value – Me.txtTax.Value
Else
Me.txtGross.Value = Sum * Me.txtRate.Value
Me.txtTax.Value = Me.txtGross * 20 / 100
Me.txtNet.value = Me.txtGross.Value – Me.txtTax.Value
End If
Me.txtDay2.Enabled = True
Me.txtDay2.SetFocus
End Sub
I’d really appreciated any help on this one as I’m slowly improving my VBA knowledge but still have a lot to learn, and as usual I’m always grateful to those with greater knowledge who take their time to help those of us with less.
Many thanks in advance
I have created a (time sheet) userform with 7 textboxes each representing a day of the week (Monday – Sunday). I have a further 4 textboxes for the Daily Rate, Gross Pay, Tax Paid and final ‘Net Pay’.
I have restricted entry in the 7 textboxes to 1 or 0. - 1 for a day worked or 0 for a day not worked.
I would like (on the change event) as the user enters 1 - the Gross, Tax and the Net Pay textboxes are automatically updated.
This requires each day worked to be multiplied by the ‘Daily Rate’ (txtRate).
I have managed to achieve the above for the first textbox (Monday) but have not been able to do so for the remaining 6 textboxes (Tuesday – Sunday).
I’ve looked on line and seen others have had similar issues but none of the solutions have worked for my purpose. If anyone has a solution the working code I’ve used in textbox 1(txtDay1) is:
Private Sub txtDay1_Change()
Me. txtDay 1.MaxLength = 1
On Error Resume Next
If Me.txtCIS.Value = "No" Or Me.txtCIS.Value = "Pending" Then
Me.txtGross.Value = Sum * Me.txtRate.Value
Me.txtTax.Value = Me.txtGross * 30 / 100
Me.txtNet.value = Me.txtGross.Value – Me.txtTax.Value
Else
Me.txtGross.Value = Sum * Me.txtRate.Value
Me.txtTax.Value = Me.txtGross * 20 / 100
Me.txtNet.value = Me.txtGross.Value – Me.txtTax.Value
End If
Me.txtDay2.Enabled = True
Me.txtDay2.SetFocus
End Sub
I’d really appreciated any help on this one as I’m slowly improving my VBA knowledge but still have a lot to learn, and as usual I’m always grateful to those with greater knowledge who take their time to help those of us with less.
Many thanks in advance