Avatar of Peter Chan
Peter Chan
Flag for Hong Kong asked on

Macro issue

Hi,
Can you help due to error "Subscript out of range" when running macro of attached file?ErrorFilter.xlsm
VB ScriptVBAMicrosoft ExcelMicrosoft Office

Avatar of undefined
Last Comment
Roy Cox

8/22/2022 - Mon
Bill Prew

Try this small change:

    On Error Resume Next
    Sheets("Output").Delete
    On Error GoTo 0

Open in new window


»bp
ASKER CERTIFIED SOLUTION
Saqib Husain

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Saqib Husain

You would also have to change

        If Mid(Item0, "-") > 0 Then

to

        If InStr(Item0, "-") > 0 Then


Roy Cox

Your code should be in a Standard Module.

I see no reason to actually delete the sheet and replace when you can simply clean up th e existing sheet.

Also, I've added a Function to save looping to check if the sheet exists.
ErrorFilter.xlsm
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy