Results 1 to 10 of 13

Thread: [Article & AddIn] How to paste into a filtered range

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member Andreas Killer's Avatar
    Join Date
    Aug 2025
    Posts
    17
    Rep Power
    0

    Question Arrays - Part Three

    The Range object simply gives us only the first range from a multiple area and everything else does not... this is strange at first, but if you think about how you want the different areas in a 2D array, you come up with at least 2 solutions:

    Vertically on top of each other or horizontally next to each other. The newer versions of Excel now also have formulas for this: VSTACK and HSTACK, in VBA we have to do this ourselves. If you're looking for the code of StackedArrays, please download the AddIn and look into the module modLowLevel.

    Code:
    
    
    Sub MultipleSourceCells_VerticalStack() Dim Source As Range, Dest As Range Dim Data 'Create the scenario ScenarioA 'Refer to some cells Set Source = Range("A4:C7,D2:E6,B9") 'Read all values into a 2D-array Data = StackedArrays(Source) 'Refer to the top left destination cell Set Dest = Range("G3") 'Resize the refered range to the same size as the array Set Dest = Dest.Resize(UBound(Data), UBound(Data, 2)) 'Write the array into the sheet Dest.Value = Data 'Just to show you what was copied Source.Select End Sub Sub MultipleSourceCells_HorizontalStack() Dim Source As Range, Dest As Range Dim Data 'Create the scenario ScenarioA 'Refer to some cells Set Source = Range("A4:C7,D2:E6,B9") 'Read all values into a 2D-array Data = StackedArrays(Source, True) 'Refer to the top left destination cell Set Dest = Range("G3") 'Resize the refered range to the same size as the array Set Dest = Dest.Resize(UBound(Data), UBound(Data, 2)) 'Write the array into the sheet Dest.Value = Data 'Just to show you what was copied Source.Select End Sub
    This brings us to the end of the first part, let's now look at how we deal with multiple areas in the finish.
    Last edited by Andreas Killer; 09-07-2025 at 05:38 PM.

Similar Threads

  1. Replies: 1
    Last Post: 07-27-2020, 12:09 AM
  2. Replies: 0
    Last Post: 09-26-2018, 02:37 PM
  3. populate control from named range stored in addin
    By MrBlackd in forum Excel Help
    Replies: 8
    Last Post: 05-11-2016, 04:46 PM
  4. Replies: 5
    Last Post: 03-25-2016, 04:28 AM
  5. Unique Count on a Filtered Range
    By Admin in forum Excel and VBA Tips and Tricks
    Replies: 0
    Last Post: 08-14-2011, 04:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •