Copy worksheet to new workbook without formulas or macro button

Tgrundy09

New Member
Joined
Jan 21, 2024
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Hello,
I need a macro that, after clicking a button, will copy the data on my worksheet to a new workbook without the formulas or macro button. Just the data on the worksheet.
In this example, I have the worksheet tab "Practice" which contains formulas, the macro button and a table of data beginning on A6.

1705852441615.png


I Need to copy the data from A6 onto a new workbook with the data only. No formulas or buttons:

1705852640994.png


This file will be shared by multiple people and will be used with varying data every time, so I want the new workbook to simply be a new workbook ("book1", "book2") etc... I don't want to reference any other saved workbook, nor do I want to assign a file location to save the new workbook. Simply enter the data, click the button to copy as text to a new workbook (keeping the table format), and allow the user to save the new file however they would like.

All I currently have is the ability to open a new workbook and copy the info exactly as the current workbook is. My VBA knowledge is very basic, so this is all I have currently:

1705852935871.png


If I need some sort of range copy and paste special feature, I'm not sure how to do this onto the new workbook.

Thank you in advance!
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
maybe like this in post 4?
 
Upvote 0
Change the name of your button (in red) to suit your needs.
Rich (BB code):
Sub NewWB()
    Application.ScreenUpdating = False
    Sheets("Practice").Copy
    With ActiveSheet
        .UsedRange.Value = .UsedRange.Value
        .Shapes.Range(Array("Button 1")).Delete
    End With
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
maybe like this in post 4?
This worked, using:
Workbooks.Add
Workbooks("Practice Macro.xls").Sheets("Practice").UsedRange.Copy
ActiveSheet.Range("A1").PasteSpecial xlPasteValuesAndNumberFormats

However, it did not copy over the table borders. Any other suggestions?
 
Upvote 0
Change the name of your button (in red) to suit your needs.
Rich (BB code):
Sub NewWB()
    Application.ScreenUpdating = False
    Sheets("Practice").Copy
    With ActiveSheet
        .UsedRange.Value = .UsedRange.Value
        .Shapes.Range(Array("Button 1")).Delete
    End With
    Application.ScreenUpdating = True
End Sub
This worked, however it copies the button over and gives me the below error:

1705855840615.png

1705855869864.png

1705855906067.png
 
Upvote 0
How did you create the button?
 
Upvote 0
Sorry but Excel vba isn't my forte - I'm better with M$ Access vba so I would have to Google how to copy table borders (and Google is how I manage to attempt to answer a lot of Excel vba questions). If the table copies over, maybe just add the borders?

It would be the same for me regarding how to solve the error you get (i.e. Googling). I believe that there are two types of buttons (that makes no sense to me) and one seems to be a shape when it's on a sheet and the other is an ActiveX control.

EDIT - I suspect that the new (copied) button name does not carry over. It is probably closer to "CommandButton1". Immediate window should be able to provide the new button name.
 
Upvote 0
This worked, using:
Workbooks.Add
Workbooks("Practice Macro.xls").Sheets("Practice").UsedRange.Copy
ActiveSheet.Range("A1").PasteSpecial xlPasteValuesAndNumberFormats

However, it did not copy over the table borders. Any other suggestions?
I got it to work with:

1705857080890.png


Thank you!
 
Upvote 0
Solution
Sorry but Excel vba isn't my forte - I'm better with M$ Access vba so I would have to Google how to copy table borders (and Google is how I manage to attempt to answer a lot of Excel vba questions). If the table copies over, maybe just add the borders?

It would be the same for me regarding how to solve the error you get (i.e. Googling). I believe that there are two types of buttons (that makes no sense to me) and one seems to be a shape when it's on a sheet and the other is an ActiveX control.

EDIT - I suspect that the new (copied) button name does not carry over. It is probably closer to "CommandButton1". Immediate window should be able to provide the new button name.
I got something to work. Thanks for the suggestions!
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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