Error 91: Object variable or With block variable not set

AndyJM87

New Member
Joined
Aug 31, 2018
Messages
28
I keep getting the aforementioned error.

I have a module (modGlobals) which I use for all public variables...

Below seems to be the offending Sub which is in a module. This code is used to populate a list box from entries on a spreadsheet.
Code:
Sub GetList()
 If Right(frmMain.Caption, 3) = "V&V" Then Set kiker = wsDataVV
 If Right(frmMain.Caption, 3) = "RGT" Then Set kiker = wsDataRGT
    With frmMain.lstAdded
        .ColumnHeads = False
        .ColumnCount = 1
        .ColumnWidths = "100"
        .RowSource = kiker.Range("B2", "B" & 1 + (kiker.Cells(Rows.Count, "B").End(xlUp).Row)).Address(external:=True)
        '.RowSource = kiker.Range("B2", kiker.Cells(Rows.Count - 1, "B").End(xlUp)).Address(external:=True)
    End With
End Sub

The below code is used from a loading form to select the activity being carried out, depending on which button clicked, depends on how the main form is set up

Code:
Private Sub cmdVV_Click()
    
    frmMain.Caption = "V&V"
    frmMain.MultiPage1.Pages(3).Visible = False
    Call createRef
    Call BuildSystemMenus
    
    frmMain.Show
    
    Unload Me
End Sub

If I comment out the code in the module, the main form loads fine.
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Sounds like one of those annoying pieces of code where it doesn't break so you don't know which line is the offender. To find out, stick a break point at the start of the code (use your mouse in the grey space to the left of a row, to highlight that row in brown) and then use F8 to step through it. It will end when it attempts to run the offending line

My hunch is that it's the .RowSource line, try splitting this out and using a string variable so you can check it pulls the right values into it
 
Upvote 0

Forum statistics

Threads
1,213,527
Messages
6,114,148
Members
448,552
Latest member
WORKINGWITHNOLEADER

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top