VBA Copy and Paste only format

x_swinson_x

New Member
Joined
Feb 10, 2016
Messages
18
I need a code that will take the range of cells from one spread sheet and paste only the formatting to the current sheet.

Here's what I have:

Worksheets("Format").Range("B15:AF39").Copy
Copy:=xlCopyFormats


Worksheets("Sheet1").Range("B15:AF39").PasteSpecial
Paste:=xlPasteFormats

I'm not very good at VBA coding can someone tweak this to make it function correctly?

excel 2015 windows 7
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Recorded macro.

Code:
Sub xx()
    Worksheets("Format").Range("B15:AF39").Copy
    Worksheets("Sheet1").Range("B15:AF39").PasteSpecial _
    Paste:=xlPasteFormats, Operation:=xlNone, _
    SkipBlanks:=False, Transpose:=False
    Application.CutCopyMode = False
End Sub
 
Upvote 0
Try this:
Code:
Sub Copy_Me()
Worksheets("Format").Range("B15:AF39").Copy
Worksheets("Sheet1").Range("B15:AF39").PasteSpecial xlPasteFormats
Application.CutCopyMode = False
End Sub
 
Upvote 0
Try this:
Code:
Sub Copy_Me()
Worksheets("Format").Range("B15:AF39").Copy
Worksheets("Sheet1").Range("B15:AF39").PasteSpecial xlPasteFormats
Application.CutCopyMode = False
End Sub

This works great but I have multiple buttons on separate pages is there a way to tweak the code so instead of "Sheet1" it would run on the current sheet? So if I'm in sheet3 and I run the macro it will run on that sheet instead of creating seperate macros for each sheet in the workbook?
 
Upvote 0
Try this:
Code:
Sub Copy_Me()
'Version2
Worksheets("Format").Range("B15:AF39").Copy
ActiveSheet.Range("B15:AF39").PasteSpecial xlPasteFormats
Application.CutCopyMode = False
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,984
Messages
6,182,136
Members
453,092
Latest member
dcasuga

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