We help IT Professionals succeed at work.

How to fix error "424" object required.

522 Views
Last Modified: 2017-04-04
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

Comment
Watch Question

Shaun VermaakSenior Consultant
CERTIFIED EXPERT
Awarded 2017
Distinguished Expert 2019

Commented:
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

ShumsManaging Director/Excel VBA Developer
CERTIFIED EXPERT
Distinguished Expert 2018

Commented:
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 PrewTest your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016

Commented:
What is the purpose of:

.Value = .Value

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

~bp
Managing Director/Excel VBA Developer
CERTIFIED EXPERT
Distinguished Expert 2018
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

Author

Commented:
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.
ShumsManaging Director/Excel VBA Developer
CERTIFIED EXPERT
Distinguished Expert 2018

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