Seeking to Copy sheets to new book- visible cells, values only & omit buttons

auto.pilot

Well-known Member
Joined
Sep 27, 2007
Messages
719
As the title says... my workbook has sheets called Summary and Detail. I recorded the following, which simply creates a new workbook with two sheets. However, the new sheets include all the formulas, filters and two buttons. I'd like to run this and display only the values, visible cells and omit the buttons on the newly created workbook.

How can I do this?

Thanks in advance.


Jim

Code:
 Sub newBook()
'
' newBook Macro
'

'
    Sheets(Array("Summary", "Detail")).Select
    Sheets("Detail").Activate
    ActiveSheet.Buttons.Add(604.5, 78, 66, 48).Select
    ActiveSheet.Buttons.Add(687.75, 86.25, 51, 36).Select
    Sheets(Array("Summary", "Detail")).Copy
End Sub
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

MattH1

Board Regular
Joined
Jul 15, 2016
Messages
174
Code:
Sub CopySpecial()

Dim wb As Workbook
Set wb= Workbooks.Add

Application.CopyObjectsWithCells=False
     Set rng = ThisWorkbook.Worksheets(TabName).Cells.SpecialCells(xlCellTypeVisible)
     rng.Copy
     wb.Worksheets("Sheet1").Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Application.CopyObjectsWithCells=True

This will copy over Visible Cells and paste their values into a new workbook. Add this to your code as you see fit.
Let me know if you have any problems with this!
 
Upvote 0

auto.pilot

Well-known Member
Joined
Sep 27, 2007
Messages
719
yes, works. In addition, I'd like to copy multiple sheets and paste with formats and column widths. I attempted to alter the code but was unable to get the desired results. Appreciate your assistance.

thanks

Jim
 
Upvote 0

Forum statistics

Threads
1,195,596
Messages
6,010,637
Members
441,558
Latest member
lambierules

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
Top