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

auto.pilot

Well-known Member
Joined
Sep 27, 2007
Messages
734
Office Version
  1. 365
Platform
  1. Windows
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

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
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
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,214,585
Messages
6,120,394
Members
448,957
Latest member
Hat4Life

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