运行-time error '91': Object variable or With block variable not set VBA

Run-time error '91': Object variable or With block variable not set VBA

我在这部分得到 Run-time error '91': Object variable or With block variable not set

  Dim cn As ADODB.Connection: Set cn = New ADODB.Connection

    schema_nm = dbsheet.cb_BU.Value

    If conn_to_SQL(cn) = False Then
        Exit Sub
    End If

    Call any_action(cn, "Load Part")
    If Not user_active = 1 Then
        Exit Sub
    End If

    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
    SkipSave = True


    If MDIsheet.AutoFilter.FilterMode = True Then MDIsheet.ShowAllData <----HERE

有什么建议吗?

它告诉您 MDIsheet 尚未分配给对象。具体来说,工作表。