Runtime error 91 object or with block variable not set

Status
Niet open voor verdere reacties.

bcva

Gebruiker
Lid geworden
6 apr 2018
Berichten
11
Goedemorgen allen,

Ik probeer een userform in te voegen die data inleest vanuit sheet 3 en 10. Dit zijn gegevens van studenten.
Die zou ik graag overzichtelijk willen maken ahv een userform, zodat de gegevens makkelijk aangepast en ingevoerd kunnen worden.

Op dit moment ziet het laden van het userform er als volgt uit:

Code:
 Private Sub UserForm_Initialize()
Application.ScreenUpdating = False

Dim Rij As Range
Dim Row As Range
    Rij = ActiveCell.Row
If Cells(Rij, 2) Is Cells.Range("B6:B55") & Not Cells(Rij, 2) Is Nothing Then
    Row = ActiveCell.Row
    Else:
    Row = Sheet3.Cells(Rows.Count, 2).End(xlUp).Offset(1).Row
End If

   NaamTextBox.Value = Cells(Row, "B").Value
   InstellingTextBox.Value = Cells(Row, "C").Value
   HoofdTextBox.Value = Cells(Row, "E").Value
   TeamTextBox.Value = Cells(Row, "D").Value
   KlinischPage.Visible = True
   AfspraakTextBox.Value = Cells(Row, "H").Value
   PlbegTextBox.Value = Cells(Row, "J").Value
   UnibegTextBox.Value = Cells(Row, "K").Value
   StartTextBox.Value = Cells(Row, "F").Value
   EindTextBox.Value = Cells(Row, "G").Value
   AfsprakenTextBox.Value = Cells(Row, "N").Value

     
    Dim Findstring As String
    Dim Rng As Range
    Findstring = TeamTextBox.Value
    If Trim(Findstring) <> "" Then
        With Sheet7.Range("B5:C200")
            Set Rng = .Find(What:=Findstring, _
                            After:=.Cells(.Cells.Count), _
                            LookIn:=xlValues, _
                            LookAt:=xlPart, _
                            SearchOrder:=xlByRows, _
                            SearchDirection:=xlNext, _
                            MatchCase:=False)
            If Not Rng Is Nothing Then
            Rng.Select
            Else
            Range("B1000").Find(xlEndUp).Select
            End If
        End With
    End If

    Rij = ActiveCell.Row
    If Cells(Rij, 2) Is Cells.Range("B6:B55") & Not Cells(Rij, 2) Is Nothing Then
    Row = ActiveCell.Row
    Else:
    Row = Sheet7.Cells(Rows.Count, 2).End(xlUp).Offset(1).Row
End If
     
KofferTextBox.Value = Cells(Row, "E").Value
     

    Findstring = NaamTextBox.Value
    If Trim(Findstring) <> "" Then
        With Sheet10.Range("B5:C200")
            Set Rng = .Find(What:=Findstring, _
                            After:=.Cells(.Cells.Count), _
                            LookIn:=xlValues, _
                            LookAt:=xlPart, _
                            SearchOrder:=xlByRows, _
                            SearchDirection:=xlNext, _
                            MatchCase:=False)
            If Not Rng Is Nothing Then
            Rng.Select
            JaOptionButton.Value = True
            Else
            Range("B1000").Find(xlEndUp).Select
            NeeOptionButton.Value = True
            End If
        End With
    End If
    
Rij = ActiveCell.Row
If Cells(Rij, 2) Is Cells.Range("B6:B55") & Not Cells(Rij, 2) Is Nothing Then
    Row = ActiveCell.Row
    Else:
    Row = Sheet10.Cells(Rows.Count, 2).End(xlUp).Offset(1).Row
End If

UnitheseTextBox.Value = Cells(Row, "D").Value
UPSBegTextBox.Value = Cells(Row, "E").Value
OndTextBox.Value = Cells(Row, "C").Value
InleidingTextBox.Value = Cells(Row, "F").Value
MethodeTextBox.Value = Cells(Row, "G").Value
ResdisTextBox.Value = Cells(Row, "H").Value
DefTextBox.Value = Cells(Row, "I").Value
BijzTextBox.Value = Cells(Row, "J").Value
    

Application.ScreenUpdating = True
End Sub

Als ik dan echter het Userform oproep dmv StudentUserForm.show krijg ik de runtime error 91: object or with block variable not set.
Ik zie even niet hoe dat komt.
zou iemand mij kunnen helpen?

Alvast heel erg bedankt!

Groet,
Bernice
 
Vertel er bij op welke regel dat gebeurt of plaats je document.
 
Plaats je document ook.
 
Kijk eens goed naar jouw variabelen en hoe je deze gedeclareerd hebt.
 
Gebruik tevens geen correct Engelse woorden als naam van een variabele.
Je eerste If condities klopt ook niet veel van.
 
Plaats je document ook.
Zie hierboven. Privacy.

Kijk eens goed naar jouw variabelen en hoe je deze gedeclareerd hebt.
Dank voor de tip!

Gebruik tevens geen correct Engelse woorden als naam van een variabele.
Je eerste If condities klopt ook niet veel van.

Niet alles is Engels ;) gaat erom dat alles wat ik declareer, later op dezelfde manier terugkomt.
If conditie ga ik nog even naar kijken, dank voor de tip.
 
Je kan de privacy gevoelige gevens wel anonimiseren lijkt me.
 
edmoor
Je kan de privacy gevoelige gevens wel anonimiseren lijkt me.

Helaas niet. Het gaat niet enkel om persoongegevens, maar ook om informatie (die bijv. in de code verwerkt zit) die ik niet vrij mag geven.
Vandaar, anders had ik met liefde een dummy document gemaakt.
 
En wat heb je gedaan met de opmerkingen in #6 en #7?
 
Een dummy zonder liefde maar met anonieme gegevens is ook goed.
Als je ervoor kiest een vraag te stellen in een openbaar forum moet je ook bereid zijn informatie te delen.
Dat is de raison d' être van een forum. Anders moet je gewoon een dienstverlener inschakelen.
 
Status
Niet open voor verdere reacties.
Steun Ons

Nieuwste berichten

Terug
Bovenaan Onderaan