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
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Do you have any merged cells or protected cells anywhere in row 20?
 
Upvote 0
Do you have any merged cells or protected cells anywhere in row 20?
Yes I do have hidden cells. i'd like those values in hidden cells to be copy and paste as special value as well.

thanks
 
Upvote 0
Which do you have in row 20, merged cells or protected cells?
 
Upvote 0
Which do you have in row 20, merged cells or protected cells?
They are not protected or merged, just hidden columns. i guess they are grouped when i click on plus sign it unhides them.
 
Upvote 0
They are not protected or merged, just hidden columns. i guess they are grouped when i click on plus sign it unhides them.
Hidden columns won't prevent you from copying.
Are there any errors in row 20?

What is the name of the module where you have placed this VBA code?
 
Upvote 0
Its under General. No there are no errors in row 20.

When i ungroup/unhide the columns and ran the code it works.

Ungroup Group Sign.png
 
Upvote 0
Ah, you didn't mention you were "grouping" rows!
Those kind of details can be important to your question!
 
Upvote 0
sorry not rows, grouping columns.

Thanks
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.
 
Upvote 0

Forum statistics

Threads
1,215,316
Messages
6,124,226
Members
449,148
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