Working with cells hidden by filtering

kingd123

New Member
Joined
Feb 18, 2006
Messages
10
Could anyone let me know how to copy a column, or blank a column,
including any rows hidden by filtering or AutoFilter ?

For example, if I have a worksheet with rows 1-10,
and AutoFilter is only showing rows 4-6:



Dim Data As Range

Set Data = ActiveSheet


' Copying column
' ==========

Data.Columns(1).Value = Data.Columns(2).Value

' Source contains all 10 rows of column 2

' However, on setting destination, effectively does following,
' which is not what I want at all

' cell(4,1) = cell(1,2)
' cell(5,1) = cell(2,2)
' cell(6,1) = cell(3,2)

' If AutoFilter is off, everything works fine:

' cell(1,1) = cell(1,2)
' cell(2,1) = cell(2,2)
' cell(3,1) = cell(3,2)
' cell(4,1) = cell(4,2)
' cell(5,1) = cell(5,2)
' cell(6,1) = cell(6,2)
' cell(7,1) = cell(7,2)
' cell(8,1) = cell(8,2)
' cell(9,1) = cell(9,2)
' cell(10,1) = cell(10,2)


' Blanking column
' ==========

Data.Columns(3).Value = ""

' Only blanks following:

' cell(4,3)
' cell(5,3)
' cell(6,3)

' I want to blank all 10 cells in column 3


I was wondering if I could do the following:

1) Save filter / AutoFilter status for worksheet
2) ShowAllData
3) Do my column copy, or column blank
4) Restore filter / AutoFilter status for worksheet


I also looked at SpecialCells(xlCellTypeAllFormatConditions).
But that appears to only return cells with conditional formatting,
not all cells, including cells hidden by filtering.


I also wondered if I should create a CustomView, with no filtering.
But I think worksheet manipulation only acts on the 'main' view.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Hi kingd123,

I suggest you just do it with a loop, like this:

Dim iRow As Long
iRow = 2
Do Until IsEmpty(Cells(iRow, "B"))
Cells(iRow, "A") = Cells(iRow, "B")
iRow = iRow + 1
Loop


Damon
 
Upvote 0

Forum statistics

Threads
1,223,247
Messages
6,171,004
Members
452,374
Latest member
keccles

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