VBA Code to Export a specific worksheet from a current workbook and create a new workbook

jmk15315

Board Regular
Joined
Nov 7, 2021
Messages
73
Office Version
  1. 2013
  2. 2010
Platform
  1. Windows
I have a "Root" spreadsheet that I want to have the ability to export a single tab from this current workbook, create a new workbook and name it based on specific cells in the old workbook.
Being self-taught I believe this can be done, but I am at a loss as to how I would accomplish this.

Here is what I have tried, but can't get to work

Sub Button6_Click()

Dim saveAsFilename As Variant

Sheet1.Select
Sheet32.Visible = True
Sheet32.Select
Sheet32.Copy
Windows("G-XXXXX - WORKING FILE.xlsm").Activate
Sheet1.Select
Windows("Book1").Activate

saveAsFilename = Application.GetSaveAsFilename( _
InitialFileName:=Application.DefaultFilePath & "\" & "P" & Sheet2.Range("G11").Value & " - Job Information Form", _
FileFilter:="xls File (*.xls), *.xls", _
Title:="Save")

If saveAsFilename = False Then Exit Sub

End Sub


Any assistance will be greatly appreciated.
 
If your vba module is set to Option Explicit then you must declare any variable used.
So add a Dim Shp as Shape to your initial declarations (but Dim Shp would also be sufficient)
That worked perfectly. Thanks for your assistance.
 
Upvote 0

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Thank you for the feedback
If that resolve the problem then it'd be better to mark the discussion as Resoved; see the procedure: Mark as Solution
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,279
Members
452,630
Latest member
OdubiYouth

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