I need to copy a range of cells and paste saving the format.

WStockel

New Member
Joined
May 30, 2020
Messages
30
Office Version
  1. 365
Platform
  1. Windows
Would like to copy Worksheets("Results").Cells(row,2), Worksheets("Results").Cells(row+2,lastCol)
and paste them to Worksheets("Results").Cells(row-8,2) and save the format (ie cell background color)
 
Last edited:

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Maybe:

Worksheets("Results").Cells(row,2), Worksheets("Results").Cells(row+2,lastCol).Copy Worksheets("Results").Cells(row-8,2)
 
Upvote 0
It says I need an "=" after the first part: Worksheets("Results").Cells(row,2)
VBA Code:
 
Upvote 0
Do you have the .Copy?

Worksheets("Results").Cells(row,2), Worksheets("Results").Cells(row+2,lastCol).Copy Worksheets("Results").Cells(row-8,2)
 
Upvote 0
VBA Code:
Yes. I just copy and pasted exactly what you have and soon as I hit enter it gives the message about needing an = sign.
 
Upvote 0
This worked:
VBA Code:
With Worksheets("Players")
.Cells(row,2), .Cells(row+2,lastCol)[B].Copy[/B] .Cells(row-8,2)
End With
 
Upvote 0
Now that I look at it a bit closer, it seems the syntax is off in both cases. Maybe:

With Worksheets("Players")
.Range(.Cells(row, 2), .Cells(row+2, lastCol)).Copy .Cells(row-8, 2)
End With

That will copy a range starting with .Cells(row, 2) and ending with .Cells(row+2, lastCol). But it sounds like you got it working to your satisfaction in any case.

(FYI: If you want to using bolding or highlighting within a VBA code snippet, use the <rich/> option instead of <vba/>.)
 
Upvote 0
Now that I look at it a bit closer, it seems the syntax is off in both cases. Maybe:

With Worksheets("Players")
.Range(.Cells(row, 2), .Cells(row+2, lastCol)).Copy .Cells(row-8, 2)
End With

That will copy a range starting with .Cells(row, 2) and ending with .Cells(row+2, lastCol). But it sounds like you got it working to your satisfaction in any case.

(FYI: If you want to using bolding or highlighting within a VBA code snippet, use the <rich/> option instead of <vba/>.)
Thanks
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,913
Members
449,093
Latest member
dbomb1414

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