DB73
Board Regular
- Joined
- Jun 7, 2022
- Messages
- 102
- Office Version
- 365
- 2021
- 2019
- 2016
- 2010
- 2007
- Platform
- Windows
- Mobile
- Web
i'm trying to figure out to prevent writing to my sheet after vbNo is choosen
if i click No, it still writes to my sheet, but i want to return to my userform to ajust the values i filled in on my userform
any help would be greatfull...
if i click No, it still writes to my sheet, but i want to return to my userform to ajust the values i filled in on my userform
any help would be greatfull...
VBA Code:
Private Sub CommandButton5_Click()
answer = MsgBox("Alles juis ingevuld", vbQuestion + vbYesNo) = vbYes
If vbYes Then
'Datum
Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Value = CDate(TheDate.Value)
'ziek/werkdag/feestdag
Range("M" & Rows.Count).End(xlUp).Offset(0, 0).Value = ComboBox1.Text
'project
Range("N" & Rows.Count).End(xlUp).Offset(0, 0).Value = ComboBox2.Text
'werk locatie
Range("Q" & Rows.Count).End(xlUp).Offset(0, 0).Value = ComboBox3.Text
'normale of over uren
Range("R" & Rows.Count).End(xlUp).Offset(0, 0).Value = ComboBox4.Text
'uur tarief percentage
Range("S" & Rows.Count).End(xlUp).Offset(0, 0).Value = ComboBox5.Text
'starttijd
Range("T" & Rows.Count).End(xlUp).Offset(0, 0).Value = ComboBox6.Text
'eindtijd
Range("U" & Rows.Count).End(xlUp).Offset(0, 0).Value = ComboBox7.Text
'pauze
Range("V" & Rows.Count).End(xlUp).Offset(0, 0).Value = ComboBox8.Text
'BTW verlegd ja/nee
Range("Y" & Rows.Count).End(xlUp).Offset(0, 0).Value = ComboBox9.Text
'BTW heffing
Range("Z" & Rows.Count).End(xlUp).Offset(0, 0).Value = ComboBox10.Text
'Rit van
Range("AD" & Rows.Count).End(xlUp).Offset(0, 0).Value = ComboBox11.Text
'Rit naar
Range("AH" & Rows.Count).End(xlUp).Offset(0, 0).Value = ComboBox12.Text
'Enkele reis of retour rit
Range("AL" & Rows.Count).End(xlUp).Offset(0, 0).Value = ComboBox13.Text
'rede rit
Range("AN" & Rows.Count).End(xlUp).Offset(0, 0).Value = ComboBox14.Text
'declaratie bedrag pkm zakelijk
Range("AO" & Rows.Count).End(xlUp).Offset(0, 0).Value = ComboBox15.Text
'overige declaratie
Range("AR" & Rows.Count).End(xlUp).Offset(0, 0).Value = ComboBox16.Text
'reden overige declaratie
Range("AS" & Rows.Count).End(xlUp).Offset(0, 0).Value = ComboBox17.Text
Exit Sub
End If
answer = MsgBox("Alles juis ingevuld", vbQuestion + vbYesNo) = vbYes
If vbYes Then
MyForm.Show
End If
End Sub