Link to home
Start Free TrialLog in
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

Avatar of Shaun Vermaak
Shaun Vermaak
Flag of Australia image

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

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

Avatar of Bill Prew
Bill Prew

What is the purpose of:

.Value = .Value

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

~bp
ASKER CERTIFIED SOLUTION
Avatar of Shums Faruk
Shums Faruk
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 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.
You're Welcome Jennifer! Glad I was able to help you :)