Save As (VBA) stopped working

SueBK

Board Regular
Joined
Aug 12, 2014
Messages
114
I have code in a macro to prompt the user to save the file, followed by a message box to say the task is complete.
Code:
    MsgBox ("Please save the report")
    file_name = Application.GetSaveAsFilename(FileFilter:="Microsoft Excel file (*.xlsx), *.xlsx")
    If file_name <> False Then
    ActiveWorkbook.SaveAs Filename:=file_name
    MsgBox "File Saved!"
    End If

    MsgBox ("All worksheets have now been created. Thank you.")

It has worked beautifully to date.

Today!!!! I get the "Please save the report" message, and then straight away the "all complete" message box and the whole *&^#@) thing hangs for ages. THEN, I can edit and make changes to my UNSAVED file, but I can't access the Home menu to save the dang thing and eventually it just falls over.
 
So, let me see if I know what's going on here. I save the first piece of code 'as is'. Then where I'm currently using "UsedRange" I would use "myUsedRange" instead, and include the dimming & setting lines?

Bring on the three day weekend and a bit of VBA oblivion. And add "public functions" to my "read up about on Monday" list.
 
Upvote 0

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Then where I'm currently using "UsedRange" I would use "myUsedRange" instead, and include the dimming & setting lines

You would use "myUsedRange" instead of "UsedRange" but no you don't need to include the dimming and setting lines as they are defined in the function.

Code:
Sub FindUsedRange()

    If myUsedRange Is Nothing Then
        MsgBox "There is no used range, the worksheet is empty."
    Else
        MsgBox "The real used range is: " & myUsedRange.Address
    End If

End Sub
 
Upvote 0

Forum statistics

Threads
1,216,756
Messages
6,132,533
Members
449,733
Latest member
Nameless_

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top