Combine two vba code snippets

shaju

Board Regular
Joined
Jul 12, 2004
Messages
80
Office Version
  1. 2010
Platform
  1. Windows
Hello all,

I have a rather big area (A1:CJ311) with some cells having Borders on all sides, some cells collectively have a thick box border etc. Most of the cells have formulae in them. I want to copy the whole range("A1:CJ311") to another location with just the bordering formats of the cells and their values, not the formulae in them.
The following codes show what I want, but is there a way to combine both of the them.

Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= xlNone, _
SkipBlanks:=False, Transpose:=False
TIA
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
You will need to do it as you have done.
 
Upvote 0
Solution
Thank you Fluff. The code was generated through macro recorder and edited . And it really suits me. Trying to shorten it down. That’s all. Once again thanks to you for looking into this matter.
 
Upvote 0
You can slim it down slightly like
Code:
With Selection
   .PasteSpecial xlPasteFormats
   .PasteSpecial xlPasteValuesAndNumberFormats
End With
But they still need to be done separately.
 
Last edited:
Upvote 0
Once again Thank you Fluff. Shortening down the code also helps.
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,305
Members
452,633
Latest member
DougMo

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