Avatar of Jennifer Liu
Jennifer Liu
 asked on

How to fix error "424" object required.

I have the following piece of code and it keeps generating error message as in the title. Can anybody help please?

 
With ActiveSheet.UsedRange
        .Value = .Value
    End With
    With NewWB
        For Each Shp In WS2.Shapes
            Shp.Delete
            ActiveWorkbook.SaveAs Filename:=FName
            .Close savechanges:=True
        Next Shp
    End With

Open in new window

VB ScriptMicrosoft OfficeVBAMicrosoft Excel

Avatar of undefined
Last Comment
Shums Faruk

8/22/2022 - Mon
Shaun Vermaak

With ActiveSheet.UsedRange
        .Value = .Value
    End With
    With NewWB
        For Each Shp In WS2.Shapes
            Shp.Delete
        Next Shp
        .SaveAs Filename:=FName
        .Close savechanges:=True
    End With

Open in new window

Shums Faruk

It doesn't seems to be full code but for piece of code try below:
With ActiveSheet.UsedRange
    .Value = .Value
End With
With NewWB
    For Each Shp In Sheets(1).Shapes
        Shp.Delete
        ThisWorkbook.SaveAs Filename:=FName
        .Close savechanges:=True
    Next Shp
End With

Open in new window

Bill Prew

What is the purpose of:

.Value = .Value

And where are NewWB and WS2 set, I don't see that happening?

~bp
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
ASKER CERTIFIED SOLUTION
Shums Faruk

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Jennifer Liu

ASKER
Thank you so much Shum for your valuable input into solving my problems with VBA code. Now I can run my reports seamlessly with the command button working in the worksheet.
Shums Faruk

You're Welcome Jennifer! Glad I was able to help you :)