How do I paste a single value to a Filtered Range and INCLUDE hidden cells?

UniMord

Active Member
Joined
May 6, 2002
Messages
311
I'd like to copy a value into a filtered range and include the hidden cells. When you're pasting a series of cells, this is the default, usually undesired, behavior.
But when the value originates from a single cell, or is a control+enter, the hidden cells are ignored. Picture a filtered table, where I want to enter FALSE into all the visible cells and everything in between (i.e., hidden). Is there any easy way to achieve this without having to clear the filter?
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
As a last resort, if there really is no native way to accomplish this, we can loop through the range, like below (Note: requires reference to Microsoft Forms 2.0 Object Library). Any ideas?

Code:
[COLOR=#E56717][B]Sub[/B][/COLOR] PasteIncludingHidden()
[COLOR=#151B8D][B]    On[/B][/COLOR] [COLOR=#151B8D][B]Error[/B][/COLOR] [COLOR=#8D38C9][B]GoTo[/B][/COLOR] Finish [COLOR=#008000]'If clipboard is empty.
    [/COLOR][COLOR=#151B8D][B]Dim[/B][/COLOR] cel [COLOR=#151B8D][B]As[/B][/COLOR] Range
[COLOR=#151B8D][B]    Dim[/B][/COLOR] DataObj [COLOR=#151B8D][B]As[/B][/COLOR] [COLOR=#E56717][B]New[/B][/COLOR] MSForms.DataObject: DataObj.GetFromClipboard
[COLOR=#151B8D][B]    Dim[/B][/COLOR] paste$: paste = DataObj.GetText: paste = Left(paste, Len(paste) - 2)
    Application.ScreenUpdating = [COLOR=#00C2FF][B]False[/B][/COLOR]
[COLOR=#8D38C9][B]    For[/B][/COLOR] [COLOR=#8D38C9][B]Each[/B][/COLOR] cel [COLOR=#8D38C9][B]In[/B][/COLOR] Selection
        cel = paste
[COLOR=#8D38C9][B]    Next[/B][/COLOR] cel
Finish:
    Application.ScreenUpdating = [COLOR=#00C2FF][B]True[/B][/COLOR]
[COLOR=#8D38C9][B]End[/B][/COLOR] [COLOR=#E56717][B]Sub[/B][/COLOR]
 
Upvote 0
Filtered cells and hidden cells act differently. From the average users perspective there is no difference, but (gotcha') there is.
If you do a normal copy from filtered cells, you will not copy what you do not see.
If you do a normal copy from hidden cells, you will copy what you do not see.

If your target range had hidden cells instead of filtered cells you'd be fine.
 
Upvote 0
Thank you, that is good information. In short, there is no non-VBA way to get at the filtered cells.
 
Upvote 0
Correction: Paste Special, Values Only, or Skip Blanks, will get the job done! Solved! (solution by p45cal at the aforementioned forum).
 
Last edited:
Upvote 0

Forum statistics

Threads
1,226,454
Messages
6,191,139
Members
453,642
Latest member
jefals

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