Copy only the visible rows in reverse

sofas

Well-known Member
Joined
Sep 11, 2022
Messages
559
Office Version
  1. 2021
  2. 2019
Platform
  1. Windows
Hi, I have this code to copy selected columns to last empty row of same selected range. Previously acquired by @Peter_SSs
Works well for me. Due to the large amount of rows in the file, I had to filter them according to a specific criterion. I currently want to modify it so I can copy only the visible rows.
If there are hidden rows, unfortunately I did not succeed. I tried to put selection.specialcells(xlcelltypevisible) to no avail.


VBA Code:
Sub macro_v3()
  Dim nextrw As Long
 
  With Selection
    nextrw = .EntireColumn.Find(What:="?*", Searchorder:=xlByRows, Searchdirection:=xlPrevious).Row + 1
    .Offset(nextrw - .Row).Value = Application.Index(Selection, Evaluate("row(1:" & .Rows.Count & ")"), Array(2, 1))
  End With
End Sub
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Hello 👋 Waiting for any suggestion that can help me
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,147
Members
453,021
Latest member
Justyna P

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