Subscript Out of Range Error in VBA

yatri82

New Member
Joined
Jul 11, 2017
Messages
1
Hey All,

I have the following code in one of my Excel files. Using it to automatically filter team based on what is selected on the home screen.
There are various charts which are then processed based on the filter selection.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

ActiveSheet.AutoFilterMode = False
Worksheets("Admin").Range("B166:V166").AutoFilter
Worksheets("Admin").Range("B166:V166").AutoFilter Field:=3, Criteria1:=Worksheets("Admin").Range("C8").Text


End Sub

All was fine until yesterday, I haven't made any major change or renamed anything in the file. Getting all sorts of errors today. Apparently, it works fine when I just select 'continue'.

Two errors I have received today.

1.) Code execution interrupted - Searched and found that this can be resolved just my hitting Cntrl+Break and/or restarting the system. Didn't happen again.

2.) Subscript out of range (Error 9)
Disappeared when I selected continue, closed and reopened the file.

I am fine if this is one-off but if these errors come, they affect user confidence in the authenticity of the reports. Scares them away, if you guys know what I mean.

Cheers! :)
 

Some videos you may like

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Watch MrExcel Video

Forum statistics

Threads
1,108,677
Messages
5,524,225
Members
409,566
Latest member
santoshsj

This Week's Hot Topics

Top