• Privacywetgeving
    Het is bij Helpmij.nl niet toegestaan om persoonsgegevens in een voorbeeld te plaatsen. Alle voorbeelden die persoonsgegevens bevatten zullen zonder opgaaf van reden verwijderd worden. In de vraag zal specifiek vermeld moeten worden dat het om fictieve namen gaat.

Controle VBA code

  • Onderwerp starter Onderwerp starter Tsw
  • Startdatum Startdatum
Status
Niet open voor verdere reacties.

Tsw

Gebruiker
Lid geworden
5 dec 2011
Berichten
183
Hallo,

Ik weet het, mijn code is veel te uitgebreid.
Maar op deze manier kom ik er later ook nog uit komen en makkelijker kan aanpassen

Code:
Private Sub cmdtoevoegen_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("DATA")

iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row

Me.CheckBox1.Value = False
Me.CheckBox1.TripleState = False
Me.CheckBox2.Value = False
Me.CheckBox2.TripleState = False
Me.CheckBox3.Value = False
Me.CheckBox3.TripleState = False
Me.CheckBox4.Value = False
Me.CheckBox4.TripleState = False
Me.CheckBox5.Value = False
Me.CheckBox5.TripleState = False
Me.CheckBox6.Value = False
Me.CheckBox6.TripleState = False
Me.CheckBox7.Value = False
Me.CheckBox7.TripleState = False
Me.CheckBox8.Value = False
Me.CheckBox8.TripleState = False
Me.CheckBox9.Value = False
Me.CheckBox9.TripleState = False
Me.CheckBox10.Value = False
Me.CheckBox10.TripleState = False
Me.CheckBox11.Value = False
Me.CheckBox11.TripleState = False
Me.CheckBox12.Value = False
Me.CheckBox12.TripleState = False


If Trim(Me.CBstatus.Value) = "" Then
Me.CBstatus.SetFocus
MsgBox "Status invullen"
Exit Sub
End If

If Trim(Me.tbnummer.Value) = "" Then
Me.CBstatus.SetFocus
MsgBox "Project nummer invullen"
Exit Sub
End If

If Trim(Me.tbnaam.Value) = "" Then
Me.tbnaam.SetFocus
MsgBox "Project naam invullen"
Exit Sub
End If

If Trim(Me.tbtekenen.Value) = "" Then
End If

If Trim(Me.tbtekenen1.Value) = "" Then
End If

If Trim(Me.tbcontrole.Value) = "" Then
End If

If Trim(Me.tbcontrole1.Value) = "" Then
End If

If Trim(Me.tbaanpassen.Value) = "" Then
End If

If Trim(Me.tbaanpassen1.Value) = "" Then
End If

If Trim(Me.tbextra.Value) = "" Then
End If

If Trim(Me.tbextra1.Value) = "" Then
End If

If Trim(Me.tbdefinitief.Value) = "" Then
End If

If Trim(Me.tbdefinitief1.Value) = "" Then
End If

If Trim(Me.tbopmerking.Value) = "" Then
End If

If Trim(Me.tbopmerking1.Value) = "" Then
End If

If Trim(Me.tblevering1.Value) = "" Then
End If

If Trim(Me.tbdeel1.Value) = "" Then
End If

If Trim(Me.tbweek1.Value) = "" Then
End If

If Trim(Me.tbdag1.Value) = "" Then
End If

If Trim(Me.tbkoz1.Value) = "" Then
End If

If Trim(Me.tbra1.Value) = "" Then
End If

If Trim(Me.tbond1.Value) = "" Then
End If

If Trim(Me.tbverb1.Value) = "" Then
End If

If Trim(Me.tblevering2.Value) = "" Then
End If

If Trim(Me.tbdeel2.Value) = "" Then
End If

If Trim(Me.tbweek2.Value) = "" Then
End If

If Trim(Me.tbdag2.Value) = "" Then
End If

If Trim(Me.tbkoz2.Value) = "" Then
End If

If Trim(Me.tbra2.Value) = "" Then
End If

If Trim(Me.tbond2.Value) = "" Then
End If

If Trim(Me.tbverb2.Value) = "" Then
End If

If Trim(Me.tblevering3.Value) = "" Then
End If

If Trim(Me.tbdeel3.Value) = "" Then
End If

If Trim(Me.tbweek3.Value) = "" Then
End If

If Trim(Me.tbdag3.Value) = "" Then
End If

If Trim(Me.tbkoz3.Value) = "" Then
End If

If Trim(Me.tbra3.Value) = "" Then
End If

If Trim(Me.tbond3.Value) = "" Then
End If

If Trim(Me.tbverb3.Value) = "" Then
End If

If Trim(Me.tblevering4.Value) = "" Then
End If

If Trim(Me.tbdeel4.Value) = "" Then
End If

If Trim(Me.tbweek4.Value) = "" Then
End If

If Trim(Me.tbdag4.Value) = "" Then
End If

If Trim(Me.tbkoz4.Value) = "" Then
End If

If Trim(Me.tbra4.Value) = "" Then
End If

If Trim(Me.tbond4.Value) = "" Then
End If

If Trim(Me.tbverb4.Value) = "" Then
End If

If Trim(Me.tblevering5.Value) = "" Then
End If

If Trim(Me.tbdeel5.Value) = "" Then
End If

If Trim(Me.tbweek5.Value) = "" Then
End If

If Trim(Me.tbdag5.Value) = "" Then
End If

If Trim(Me.tbkoz5.Value) = "" Then
End If

If Trim(Me.tbra5.Value) = "" Then
End If

If Trim(Me.tbond5.Value) = "" Then
End If

If Trim(Me.tbverb5.Value) = "" Then
End If

If Trim(Me.tblevering6.Value) = "" Then
End If

If Trim(Me.tbdeel6.Value) = "" Then
End If

If Trim(Me.tbweek6.Value) = "" Then
End If

If Trim(Me.tbdag6.Value) = "" Then
End If

If Trim(Me.tbkoz6.Value) = "" Then
End If

If Trim(Me.tbra6.Value) = "" Then
End If

If Trim(Me.tbond6.Value) = "" Then
End If

If Trim(Me.tbverb6.Value) = "" Then
End If

If Trim(Me.tblevering7.Value) = "" Then
End If

If Trim(Me.tbdeel7.Value) = "" Then
End If

If Trim(Me.tbweek7.Value) = "" Then
End If

If Trim(Me.tbdag7.Value) = "" Then
End If

If Trim(Me.tbkoz7.Value) = "" Then
End If

If Trim(Me.tbra7.Value) = "" Then
End If

If Trim(Me.tbond7.Value) = "" Then
End If

If Trim(Me.tbverb7.Value) = "" Then
End If

If Trim(Me.tblevering8.Value) = "" Then
End If

If Trim(Me.tbdeel8.Value) = "" Then
End If

If Trim(Me.tbweek8.Value) = "" Then
End If

If Trim(Me.tbdag8.Value) = "" Then
End If

If Trim(Me.tbkoz8.Value) = "" Then
End If

If Trim(Me.tbra8.Value) = "" Then
End If

If Trim(Me.tbond8.Value) = "" Then
End If

If Trim(Me.tbverb8.Value) = "" Then
End If

If Trim(Me.tblevering9.Value) = "" Then
End If

If Trim(Me.tbdeel9.Value) = "" Then
End If

If Trim(Me.tbweek9.Value) = "" Then
End If

If Trim(Me.tbdag9.Value) = "" Then
End If

If Trim(Me.tbkoz9.Value) = "" Then
End If

If Trim(Me.tbra9.Value) = "" Then
End If

If Trim(Me.tbond9.Value) = "" Then
End If

If Trim(Me.tbverb9.Value) = "" Then
End If

If Trim(Me.tblevering10.Value) = "" Then
End If

If Trim(Me.tbdeel10.Value) = "" Then
End If

If Trim(Me.tbweek10.Value) = "" Then
End If

If Trim(Me.tbdag10.Value) = "" Then
End If

If Trim(Me.tbkoz10.Value) = "" Then
End If

If Trim(Me.tbra10.Value) = "" Then
End If

If Trim(Me.tbond10.Value) = "" Then
End If

If Trim(Me.tbverb10.Value) = "" Then
End If

If Trim(Me.tblevering11.Value) = "" Then
End If

If Trim(Me.tbdeel11.Value) = "" Then
End If

If Trim(Me.tbweek11.Value) = "" Then
End If

If Trim(Me.tbdag11.Value) = "" Then
End If

If Trim(Me.tbkoz11.Value) = "" Then
End If

If Trim(Me.tbra11.Value) = "" Then
End If

If Trim(Me.tbond11.Value) = "" Then
End If

If Trim(Me.tbverb11.Value) = "" Then
End If

If Trim(Me.tblevering12.Value) = "" Then
End If

If Trim(Me.tbdeel12.Value) = "" Then
End If

If Trim(Me.tbweek12.Value) = "" Then
End If

If Trim(Me.tbdag12.Value) = "" Then
End If

If Trim(Me.tbkoz12.Value) = "" Then
End If

If Trim(Me.tbra12.Value) = "" Then
End If

If Trim(Me.tbond12.Value) = "" Then
End If

If Trim(Me.tbverb12.Value) = "" Then

If Trim(Me.CheckBox1.Value) = "" Then
If Trim(Me.CheckBox2.Value) = "" Then
If Trim(Me.CheckBox3.Value) = "" Then
If Trim(Me.CheckBox4.Value) = "" Then
If Trim(Me.CheckBox5.Value) = "" Then
If Trim(Me.CheckBox6.Value) = "" Then
If Trim(Me.CheckBox7.Value) = "" Then
If Trim(Me.CheckBox8.Value) = "" Then
If Trim(Me.CheckBox9.Value) = "" Then
If Trim(Me.CheckBox10.Value) = "" Then
If Trim(Me.CheckBox11.Value) = "" Then
If Trim(Me.CheckBox12.Value) = "" Then
End If

ws.Cells(iRow, 3).Value = Me.CBstatus.Value
ws.Cells(iRow, 1).Value = Me.tbnummer.Value
ws.Cells(iRow, 2).Value = Me.tbnaam.Value
ws.Cells(iRow, 4).Value = Me.tbopmerking.Value
ws.Cells(iRow, 5).Value = Me.tbopmerking1.Value
ws.Cells(iRow, 6).Value = Me.tbtekenen.Value
ws.Cells(iRow, 7).Value = Me.tbtekenen1.Value
ws.Cells(iRow, 8).Value = Me.tbcontrole.Value
ws.Cells(iRow, 9).Value = Me.tbcontrole1.Value
ws.Cells(iRow, 10).Value = Me.tbaanpassen.Value
ws.Cells(iRow, 11).Value = Me.tbaanpassen1.Value
ws.Cells(iRow, 12).Value = Me.tbextra.Value
ws.Cells(iRow, 13).Value = Me.tbextra1.Value
ws.Cells(iRow, 14).Value = Me.tbdefinitief.Value
ws.Cells(iRow, 15).Value = Me.tbdefinitief1.Value


ws.Cells(iRow, 16).Value = Me.tblevering1.Value
ws.Cells(iRow, 17).Value = Me.tbdeel1.Value
ws.Cells(iRow, 18).Value = Me.tbweek1.Value
ws.Cells(iRow, 19).Value = Me.tbdag1.Value
ws.Cells(iRow, 20).Value = Me.tbkoz1.Value
ws.Cells(iRow, 21).Value = Me.tbra1.Value
ws.Cells(iRow, 22).Value = Me.tbond1.Value
ws.Cells(iRow, 23).Value = Me.tbverb1.Value
ws.Cells(iRow, 24).Value = Me.CheckBox1.Value

ws.Cells(iRow, 25).Value = Me.tblevering2.Value
ws.Cells(iRow, 26).Value = Me.tbdeel2.Value
ws.Cells(iRow, 27).Value = Me.tbweek2.Value
ws.Cells(iRow, 28).Value = Me.tbdag2.Value
ws.Cells(iRow, 29).Value = Me.tbkoz2.Value
ws.Cells(iRow, 30).Value = Me.tbra2.Value
ws.Cells(iRow, 31).Value = Me.tbond2.Value
ws.Cells(iRow, 32).Value = Me.tbverb2.Value
ws.Cells(iRow, 33).Value = Me.CheckBox2.Value

ws.Cells(iRow, 34).Value = Me.tblevering3.Value
ws.Cells(iRow, 35).Value = Me.tbdeel3.Value
ws.Cells(iRow, 36).Value = Me.tbweek3.Value
ws.Cells(iRow, 37).Value = Me.tbdag3.Value
ws.Cells(iRow, 38).Value = Me.tbkoz3.Value
ws.Cells(iRow, 39).Value = Me.tbra3.Value
ws.Cells(iRow, 40).Value = Me.tbond3.Value
ws.Cells(iRow, 41).Value = Me.tbverb3.Value
ws.Cells(iRow, 42).Value = Me.CheckBox3.Value

ws.Cells(iRow, 43).Value = Me.tblevering4.Value
ws.Cells(iRow, 44).Value = Me.tbdeel4.Value
ws.Cells(iRow, 45).Value = Me.tbweek4.Value
ws.Cells(iRow, 46).Value = Me.tbdag4.Value
ws.Cells(iRow, 47).Value = Me.tbkoz4.Value
ws.Cells(iRow, 48).Value = Me.tbra4.Value
ws.Cells(iRow, 49).Value = Me.tbond4.Value
ws.Cells(iRow, 50).Value = Me.tbverb4.Value
ws.Cells(iRow, 51).Value = Me.CheckBox4.Value

ws.Cells(iRow, 52).Value = Me.tblevering5.Value
ws.Cells(iRow, 53).Value = Me.tbdeel5.Value
ws.Cells(iRow, 54).Value = Me.tbweek5.Value
ws.Cells(iRow, 55).Value = Me.tbdag5.Value
ws.Cells(iRow, 56).Value = Me.tbkoz5.Value
ws.Cells(iRow, 57).Value = Me.tbra5.Value
ws.Cells(iRow, 58).Value = Me.tbond5.Value
ws.Cells(iRow, 59).Value = Me.tbverb5.Value
ws.Cells(iRow, 60).Value = Me.CheckBox5.Value

ws.Cells(iRow, 61).Value = Me.tblevering6.Value
ws.Cells(iRow, 62).Value = Me.tbdeel6.Value
ws.Cells(iRow, 63).Value = Me.tbweek6.Value
ws.Cells(iRow, 64).Value = Me.tbdag6.Value
ws.Cells(iRow, 65).Value = Me.tbkoz6.Value
ws.Cells(iRow, 66).Value = Me.tbra6.Value
ws.Cells(iRow, 67).Value = Me.tbond6.Value
ws.Cells(iRow, 68).Value = Me.tbverb6.Value
ws.Cells(iRow, 69).Value = Me.CheckBox6.Value

ws.Cells(iRow, 70).Value = Me.tblevering7.Value
ws.Cells(iRow, 71).Value = Me.tbdeel7.Value
ws.Cells(iRow, 72).Value = Me.tbweek7.Value
ws.Cells(iRow, 73).Value = Me.tbdag7.Value
ws.Cells(iRow, 74).Value = Me.tbkoz7.Value
ws.Cells(iRow, 75).Value = Me.tbra7.Value
ws.Cells(iRow, 76).Value = Me.tbond7.Value
ws.Cells(iRow, 77).Value = Me.tbverb7.Value
ws.Cells(iRow, 78).Value = Me.CheckBox7.Value

ws.Cells(iRow, 79).Value = Me.tblevering8.Value
ws.Cells(iRow, 80).Value = Me.tbdeel8.Value
ws.Cells(iRow, 81).Value = Me.tbweek8.Value
ws.Cells(iRow, 82).Value = Me.tbdag8.Value
ws.Cells(iRow, 83).Value = Me.tbkoz8.Value
ws.Cells(iRow, 84).Value = Me.tbra8.Value
ws.Cells(iRow, 85).Value = Me.tbond8.Value
ws.Cells(iRow, 86).Value = Me.tbverb8.Value
ws.Cells(iRow, 87).Value = Me.CheckBox8.Value

ws.Cells(iRow, 88).Value = Me.tblevering9.Value
ws.Cells(iRow, 89).Value = Me.tbdeel9.Value
ws.Cells(iRow, 90).Value = Me.tbweek9.Value
ws.Cells(iRow, 91).Value = Me.tbdag9.Value
ws.Cells(iRow, 92).Value = Me.tbkoz9.Value
ws.Cells(iRow, 93).Value = Me.tbra9.Value
ws.Cells(iRow, 94).Value = Me.tbond9.Value
ws.Cells(iRow, 95).Value = Me.tbverb9.Value
ws.Cells(iRow, 96).Value = Me.CheckBox9.Value

ws.Cells(iRow, 97).Value = Me.tblevering10.Value
ws.Cells(iRow, 98).Value = Me.tbdeel10.Value
ws.Cells(iRow, 99).Value = Me.tbweek10.Value
ws.Cells(iRow, 100).Value = Me.tbdag10.Value
ws.Cells(iRow, 101).Value = Me.tbkoz10.Value
ws.Cells(iRow, 102).Value = Me.tbra10.Value
ws.Cells(iRow, 103).Value = Me.tbond10.Value
ws.Cells(iRow, 104).Value = Me.tbverb10.Value
ws.Cells(iRow, 105).Value = Me.CheckBox10.Value

ws.Cells(iRow, 106).Value = Me.tblevering11.Value
ws.Cells(iRow, 107).Value = Me.tbdeel11.Value
ws.Cells(iRow, 108).Value = Me.tbweek11.Value
ws.Cells(iRow, 109).Value = Me.tbdag11.Value
ws.Cells(iRow, 110).Value = Me.tbkoz11.Value
ws.Cells(iRow, 111).Value = Me.tbra11.Value
ws.Cells(iRow, 112).Value = Me.tbond11.Value
ws.Cells(iRow, 113).Value = Me.tbverb11.Value
ws.Cells(iRow, 114).Value = Me.CheckBox11.Value

ws.Cells(iRow, 115).Value = Me.tblevering12.Value
ws.Cells(iRow, 116).Value = Me.tbdeel12.Value
ws.Cells(iRow, 117).Value = Me.tbweek12.Value
ws.Cells(iRow, 118).Value = Me.tbdag12.Value
ws.Cells(iRow, 119).Value = Me.tbkoz12.Value
ws.Cells(iRow, 120).Value = Me.tbra12.Value
ws.Cells(iRow, 121).Value = Me.tbond12.Value
ws.Cells(iRow, 122).Value = Me.tbverb12.Value
ws.Cells(iRow, 123).Value = Me.CheckBox12.Value

Me.CBstatus.Value = ""
Me.tbnummer.Value = ""
Me.tbnaam.Value = ""
Me.tbtekenen.Value = ""
Me.tbtekenen1.Value = ""
Me.tbcontrole.Value = ""
Me.tbcontrole1.Value = ""
Me.tbaanpassen.Value = ""
Me.tbaanpassen1.Value = ""
Me.tbextra.Value = ""
Me.tbextra1.Value = ""
Me.tbdefinitief.Value = ""
Me.tbdefinitief1.Value = ""
Me.tbopmerking.Value = ""
Me.tbopmerking1.Value = ""

Me.tblevering1.Value = ""
Me.tbdeel1.Value = ""
Me.tbweek1.Value = ""
Me.tbdag1.Value = ""
Me.tbkoz1.Value = ""
Me.tbra1.Value = ""
Me.tbond1.Value = ""
Me.tbverb1.Value = ""

Me.tblevering2.Value = ""
Me.tbdeel2.Value = ""
Me.tbweek2.Value = ""
Me.tbdag2.Value = ""
Me.tbkoz2.Value = ""
Me.tbra2.Value = ""
Me.tbond2.Value = ""
Me.tbverb2.Value = ""

Me.tblevering3.Value = ""
Me.tbdeel3.Value = ""
Me.tbweek3.Value = ""
Me.tbdag3.Value = ""
Me.tbkoz3.Value = ""
Me.tbra3.Value = ""
Me.tbond3.Value = ""
Me.tbverb3.Value = ""

Me.tblevering4.Value = ""
Me.tbdeel4.Value = ""
Me.tbweek4.Value = ""
Me.tbdag4.Value = ""
Me.tbkoz4.Value = ""
Me.tbra4.Value = ""
Me.tbond4.Value = ""
Me.tbverb4.Value = ""

Me.tblevering5.Value = ""
Me.tbdeel5.Value = ""
Me.tbweek5.Value = ""
Me.tbdag5.Value = ""
Me.tbkoz5.Value = ""
Me.tbra5.Value = ""
Me.tbond5.Value = ""
Me.tbverb5.Value = ""

Me.tblevering6.Value = ""
Me.tbdeel6.Value = ""
Me.tbweek6.Value = ""
Me.tbdag6.Value = ""
Me.tbkoz6.Value = ""
Me.tbra6.Value = ""
Me.tbond6.Value = ""
Me.tbverb6.Value = ""

Me.tblevering7.Value = ""
Me.tbdeel7.Value = ""
Me.tbweek7.Value = ""
Me.tbdag7.Value = ""
Me.tbkoz7.Value = ""
Me.tbra7.Value = ""
Me.tbond7.Value = ""
Me.tbverb7.Value = ""

Me.tblevering8.Value = ""
Me.tbdeel8.Value = ""
Me.tbweek8.Value = ""
Me.tbdag8.Value = ""
Me.tbkoz8.Value = ""
Me.tbra8.Value = ""
Me.tbond8.Value = ""
Me.tbverb8.Value = ""

Me.tblevering9.Value = ""
Me.tbdeel9.Value = ""
Me.tbweek9.Value = ""
Me.tbdag9.Value = ""
Me.tbkoz9.Value = ""
Me.tbra9.Value = ""
Me.tbond9.Value = ""
Me.tbverb9.Value = ""

Me.tblevering10.Value = ""
Me.tbdeel10.Value = ""
Me.tbweek10.Value = ""
Me.tbdag10.Value = ""
Me.tbkoz10.Value = ""
Me.tbra10.Value = ""
Me.tbond10.Value = ""
Me.tbverb10.Value = ""

Me.tblevering11.Value = ""
Me.tbdeel11.Value = ""
Me.tbweek11.Value = ""
Me.tbdag11.Value = ""
Me.tbkoz11.Value = ""
Me.tbra11.Value = ""
Me.tbond11.Value = ""
Me.tbverb11.Value = ""

Me.tblevering12.Value = ""
Me.tbdeel12.Value = ""
Me.tbweek12.Value = ""
Me.tbdag12.Value = ""
Me.tbkoz12.Value = ""
Me.tbra12.Value = ""
Me.tbond12.Value = ""
Me.tbverb12.Value = ""

Me.CheckBox1.Value = ""
Me.CheckBox2.Value = ""
Me.CheckBox3.Value = ""
Me.CheckBox4.Value = ""
Me.CheckBox5.Value = ""
Me.CheckBox6.Value = ""
Me.CheckBox7.Value = ""
Me.CheckBox8.Value = ""
Me.CheckBox9.Value = ""
Me.CheckBox10.Value = ""
Me.CheckBox11.Value = ""
Me.CheckBox12.Value = ""

End Sub

Maar hier zit een fout in,

maar waar moet ik die aanpassen? Kom er maar niet uit waar de fout vandaan komt.

Komt 1 van jullie hier uit?
 
Als je zegt een fout te krijgen is het ook handig erbij te vertellen welke dat dan is.
Ben je er al eens in Debug mode doorheen gegaan? Dan kom je vanzelf de regel tegen waar het fout gaat.
 
Laat maar, lost zichzelf al op. :)
 
Laatst bewerkt:
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan