Cut / Paste Hidden Rows ONLY

danjw_98

Active Member
Joined
Oct 25, 2003
Messages
354
I was wondering if there was some way to cut and paste ONLY the hidden rows on a sheet and paste them to a different sheet? appreciate any help that could be provided.
 

Excel Facts

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

Code:
Sub CopyHidden()
Dim LastRow As Integer
Dim NextRow As Integer
Dim Dest As Worksheet
Set Dest = Worksheets("Sheet2") 'This is where you want your rows copied to.
LastRow = ActiveSheet.Range("A50000").End(xlUp).Row 'Assuming there is data in ColA. If not change A to a Col that has data in your table.
 
For r = LastRow To 1 Step -1
If ActiveSheet.Cells(r, 1).EntireRow.Hidden = True Then
NextRow = Dest.Range("A50000").End(xlUp).Offset(1, 0).Row 'Again assumes your destination worksheet has data in ColA. If not change A to a Col that has data in your table.
Dest.Cells(NextRow, 1).EntireRow.Value = ActiveSheet.Cells(r, 1).EntireRow.Value
ActiveSheet.Cells(r, 1).EntireRow.Delete
End If
Next

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,286
Members
452,902
Latest member
Knuddeluff

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