How to copy format and value only?

London12F

Board Regular
Joined
Jun 21, 2016
Messages
59
The VBA below can form a new sheet and then copy used range of existing sheet to this new sheet.

Code:
Sub yMacro1()

    Dim wsNewSheet  As Worksheet
    Dim wsMySheet   As Worksheet
  
    Set wsNewSheet = Sheets.Add(Before:=Worksheets(1))
    
    For Each wsMySheet In ThisWorkbook.Sheets
        If wsMySheet.Name <> wsNewSheet.Name Then
                wsMySheet.UsedRange.Copy Destination:=wsNewSheet.Range("A1")
        End If
    Next wsMySheet
End Sub


How to revise the VBA so that it copies format and value only, (instead of copy all)?
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Do a copy and a pastespecial xlpastevalues and another for copy and pastespecial xlpasteformats. e.g.
Code:
wsMySheet.UsedRange.Copy
wsNewSheet.Range("A1").PasteSpecial xlPasteValues
wsMySheet.UsedRange.Copy
wsNewSheet.Range("A1").PasteSpecial xlPasteFormats
Application.CutCopyMode = False
 
Last edited:
Upvote 0

Forum statistics

Threads
1,225,628
Messages
6,186,103
Members
453,337
Latest member
fiaz ahmad

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