Hello Everyone,

My issue is pretty much stated in the title of this thread. When I run a macro through a Form Controls button, it skips part of the process. However, when I rerun that same macro by going to the Developer tab in the ribbon and then choosing the macro from the Macros button, it works fine.

Has anyone ever had this issue, or does anyone know what might cause it?

In case it helps, here is the code:


Sub ReportMacro2()

Application.ScreenUpdating = False

Dim rRange As Range, rCell As Range
Dim wSheet As Worksheet
Dim wSheetStart As Worksheet
Dim CompanyList As String

Set wSheetStart = Worksheets("AB - CDE")
wSheetStart.AutoFilterMode = False
'Set a range variable to the correct item column
Set rRange = Range("B2", Range("B10000").End(xlUp))
'Delete any sheet called "UniqueList"
'Turn off run time errors & delete alert
On Error Resume Next
Application.DisplayAlerts = False
Worksheets("UniqueList").Delete
'Add a sheet called "UniqueList"
Worksheets.Add().Name = "UniqueList"
'Filter the Set range so only a unique list is created
With Worksheets("UniqueList")
rRange.AdvancedFilter xlFilterCopy, , _
Worksheets("UniqueList").Range("B1"), True
'Set a range variable to the unique list, less the heading.
Set rRange = .Range("B2", Range("B10000").End(xlUp))
End With
            
On Error Resume Next
With wSheetStart
For Each rCell In rRange
CompanyList = rCell
.Range("B2").AutoFilter 2, CompanyList
Worksheets(CompanyList).Delete
'Add sheet named as content of rCell
Worksheets.Add(After:=Sheets(Worksheets.Count)).Name = CompanyList
'Copy the visible filtered range and leave hidden rows
.UsedRange.Copy Destination:=ActiveSheet.Range("A1")
ActiveSheet.Cells.Columns.AutoFit
Next rCell
End With

Sheets("Company").Delete

With wSheetStart
.AutoFilterMode = False
.Activate
End With
        
On Error GoTo 0

Dim ws As Worksheet
For Each ws In Worksheets
    ws.Activate
    ActiveWindow.Zoom = 85
Next

Application.ScreenUpdating = True

End Sub

Thanks!