Easy VBA.. Copy + Paste formatting...error 404?

billyheanue

Board Regular
Joined
Jul 13, 2015
Messages
109
Hi everyone. I have code that succeeds in expanding the current selection (CurrentRegion) to include one more column. It does that great. But when I added in lines (4) and (8), i get a error 404.

Heres what I got:

Code:
Private Sub CommandButton3_Click()Set Rng = Range("L5").CurrentRegion
Rng.Select
Sheets(1).Rng.Copy
numRows = Selection.Rows.Count
numColumns = Selection.Columns.Count
Selection.resize(numRows + 0, numColumns + 1).Select
Sheets(1).CurrentSelection.PasteSpecial xlPasteFormats


End Sub

is something wrong with "Sheets(1).Rng.Copy" or "Sheets(1).CurrentSelection.PasteSpecial xlPasteFormats" ?
I am trying to copy the old formatting, and later paste it into the new selection once the current region has been expanded.

Thanks everyone,
Bill
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Try just Rng.Copy without the Sheet(1)

and change
Sheets(1).CurrentSelection.PasteSpecial xlPasteFormats

to

Selection.PasteSpecial xlPasteFormats
 
Upvote 0
Test this on a copy of your document.

Code:
Rng.Copy
numRows = Selection.Rows.Count
numColumns = Selection.Columns.Count
Selection.Resize(numRows + 0, numColumns + 1).Select
Selection.PasteSpecial Paste:=xlPasteFormats
 
Upvote 0

Forum statistics

Threads
1,216,484
Messages
6,130,936
Members
449,608
Latest member
jacobmudombe

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