Consulting

Results 1 to 1 of 1

Thread: Autofill Destination Offset

  1. #1
    VBAX Regular
    Joined
    Oct 2018
    Posts
    34
    Location

    Autofill Destination Offset

    Hey Everyone!

    I am experiencing some trouble with the autofill destination. I would like to offset a range (with multiple selection) but I have a run-time error.

    Here is the code:

    Dim rg As Range
    Set rg = Union(Range("C2:C3"), Range("C28:C33"), Range("C58:C67"))
    
    rg.AutoFill Destination:=rg.Offset(, 2) ''This line is obvisouly wrong but can't figure why...
    Any clue?

    Thanks a lot!

    Edit:

    I've come up with this solution, but would like to know if there is another way to proceed:

    Dim rg As Range
    Set rg = Union(Range("C2:C3"), Range("C28:C33"), Range("C58:C67"))
    Set rg2 = Union(Range("C2:C3"), Range("C28:C33"), Range("C58:C67")).Resize(,c) ''only issue is that c is an integer but it still works
    
    rg.AutoFill Destination:=rg2
    Edit2:

    My mistake, I looked into the property of the "AutoFill"
    Destination must include source range
    A resize does the trick.
    Last edited by Edmond; 04-17-2019 at 07:14 AM.
    Edmond

Posting Permissions

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