Copy Entire Row and Paste as Special Value with VBA

Dokat

Active Member
Joined
Jan 19, 2015
Messages
304
Office Version
  1. 365
Hi,

I am trying to copy entire row 20 and paste as special value on same row.

I am using below code however receiving Run-time error '1004" error because paste function. Can anyone help me with the error?

Sub CopyPaste()

Application.ScreenUpdating = False

Dim wb As Workbook
Dim ws As Worksheet
Set wb = ActiveWorkbook
Set ws = Sheets("Summary by L5")
wb.Activate
ws.Select

ws.Rows(20).EntireRow.Copy
ws.Rows(20).PasteSpecial Paste:=xlPasteValues
Application.ScreenUpdating = True
End Sub
 
Yes, when posting these sorts of questions, you want to be as descriptive as possible, including all details pertaining to the rows.
Remember, we cannot see your sheet. So we are dependent upon you to provide us with all the important details.
Quite honestly i didn't even think of that as an issue until you brought it up that's why I didn't include it in the question.

VBA Code:
ws.Columns("A:GK").Columns.Ungroup

I put a code to ungroup it but now i started getting runtime error again

Thanks
 
Last edited:
Upvote 0

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Turn on your Macro Recorder, and record yourself ungrouping it manually.
Then stop your recorder, and look at the code you just recorded, and copy/paste the pertinent pasts of that into your code.
 
Upvote 0
Thanks
Turn on your Macro Recorder, and record yourself ungrouping it manually.
Then stop your recorder, and look at the code you just recorded, and copy/paste the pertinent pasts of that into your code.
Thanks
 
Upvote 0

Forum statistics

Threads
1,215,313
Messages
6,124,201
Members
449,147
Latest member
sweetkt327

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