VBA Runtime Error with XLSB file

D3allamerican07

Board Regular
Joined
Jul 22, 2015
Messages
101
I have a large macro enabled file I saved as a XLSB to reduce size and opening time. Now however, if it is not the first excel file open, I get a Runtime Error '1004' when my macro events run. However, when it is the first file open, the macro events perform perfectly.

Hopefully someone has the answer to this infuriating problem. Thanks.
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
What line of code throws the error?

Can you post the complete code?
 
Upvote 0
Code:
Private Sub oCombo1_Change()
[B]Sheets("Sheet1").Range("A:E").ClearContents[/B]

    Sheets("FESheets").AutoFilterMode = False
    Sheets("FESheets").Columns("A:H").AutoFilter Field:=1, Criteria1:=oCombo1.Value
        
LR = Sheets("FESheets").Range("B" & Rows.Count).End(xlUp).Row

Sheets("FESheets").Range("B2:C" & LR).SpecialCells(xlCellTypeVisible).Copy Destination:=Sheets("Sheet1").Range("A1")

Sheets("Sheet1").Range("A:A").AdvancedFilter _
    Action:=xlFilterCopy, _
   CopyToRange:=Sheets("Sheet1").Range("C1"), _
    Unique:=True
    
Sheets("Sheet1").Range("B:B").AdvancedFilter _
    Action:=xlFilterCopy, _
   CopyToRange:=Sheets("Sheet1").Range("D1"), _
    Unique:=True

LR2 = Sheets("Sheet1").Range("C" & Rows.Count).End(xlUp).Row

    For X = 1 To LR2
        Sheets("Sheet1").Range("E" & X).Value = Sheets("Sheet1").Range("C" & X).Value & " - " & Sheets("Sheet1").Range("D" & X).Value
    Next X


    For I = 1 To LR2
        oCB2.ListFillRange = "Sheet1!E2:E" & LR2
    Next I
    
    oCB3.ListFillRange = ""

End Sub

It errors out on the line 2 (bolded code)
 
Upvote 0
Try fully qualifying the object:

Code:
Private Sub ComboBox1_Change()
Workbooks("uform").Sheets("Sheet1").Range("A:E").ClearContents
End Sub
 
Upvote 0
Where is the control? Is it on a worksheet and linked to cells?
 
Upvote 0
- Is it a form or ActiveX control?
- How are you using it, typing or selecting from a list?
- If it’s a list, how is it populated?
 
Upvote 0
I had an ActiveX control populated manually and then a second ActiveX combo box populated from a filtered list upon the selection of the first.

However I had it as a ComboBox_Change event. Changed it to a ComboBox_DropDownList and it has been working perfectly. I appreciate everyone's help though.
 
Upvote 0

Forum statistics

Threads
1,214,627
Messages
6,120,610
Members
448,973
Latest member
ChristineC

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