Macro: flatten sheet, delete other tab, and save

steallan

Active Member
Joined
Oct 20, 2004
Messages
308
Hello - wondering if any vba experts can help me with what is a simple macro, but yet still well beyond my ability to write.

I have a workbook with a form where the user enteres a ID number, and then the rest of the form auto fills thanks to the formulas.

Now they need to be able to email it, and the backing data tab is enormous.

Can anyone write me a macro that:
1. Copies and pastes the whole of the Form tab as values, so converting all the formulas to their values.
2. Deletes the Data tab.
3. Saves the file as Save As.

So it'd open up the Save as box and stop there, so the user can then save it whereever they like. I'll then save the macro to a button on the Form tab.

Any help would be massively appreciated, my pathetic attempts to record such a macro......i shouldnt even admit i tried recording a macro. Its just sad.

Thank you

Ste
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Perhaps the below will get you started:
VBA Code:
Sub test()
    Sheets("Form").Copy
    ActiveSheet.UsedRange.Copy
    ActiveSheet.UsedRange.PasteSpecial xlValues
    Application.Dialogs(xlDialogSaveAs).Show
End Sub
 
Upvote 0
Another option
VBA Code:
Sub steallan()
    With Worksheets("Form").UsedRange
        .Value = .Value
    End With
    Application.DisplayAlerts = False
    Worksheets("Data").Delete
    Application.DisplayAlerts = True
    Application.GetSaveAsFilename
End Sub
 
Upvote 0
Perhaps the below will get you started:
VBA Code:
Sub test()
    Sheets("Form").Copy
    ActiveSheet.UsedRange.Copy
    ActiveSheet.UsedRange.PasteSpecial xlValues
    Application.Dialogs(xlDialogSaveAs).Show
End Sub
Worked a treat, thank you sir
 
Upvote 0
Another option
VBA Code:
Sub steallan()
    With Worksheets("Form").UsedRange
        .Value = .Value
    End With
    Application.DisplayAlerts = False
    Worksheets("Data").Delete
    Application.DisplayAlerts = True
    Application.GetSaveAsFilename
End Sub

Thank you, much appreciated
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,312
Members
452,634
Latest member
cpostell

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