none
Autofill VBA Button RRS feed

  • Question

  • Hello all

    We have this sheet:



    And we´re trying to create the autofill button "Fill Conditional Statements" like this:

    - The source range is Z3 to AF3 (it has values and formulas referencing other cells)
    - The destination range is Z7 to AF506

    - And if possible, join it with the other button ("Clear Order Description") which is simply:

    Private Sub ClearOrderStatuses_Click()
        Call Range(RANGE_ORDER_STATUSES).ClearContents
    End Sub

    Can anyone please help?

    Here´s the sample file:
    https://www.mediafire.com/?ao60yjuq7ft0apm

    Saturday, November 26, 2016 7:52 PM

Answers

  • Hi,

    Please visit Range.AutoFill Method (Excel)

    Destination

    Required

    Range

    The cells to be filled. The destination must include the source range.

    So to skip some rows, we could paste into the first row of the destination range and autofill then.

    Sub test()

        Range("Z3:AF3").Select

        Selection.Copy

        Range("Z7").Select

        ActiveSheet.Paste

        Application.CutCopyMode = False

        Selection.AutoFill Destination:=Range("Z7:AF506")

    End Sub

    Besides, what do you mean "Join it with other button"?

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by NicoPer Monday, November 28, 2016 6:04 PM
    Monday, November 28, 2016 9:56 AM
    Moderator

All replies

  • Hi,

    Please visit Range.AutoFill Method (Excel)

    Destination

    Required

    Range

    The cells to be filled. The destination must include the source range.

    So to skip some rows, we could paste into the first row of the destination range and autofill then.

    Sub test()

        Range("Z3:AF3").Select

        Selection.Copy

        Range("Z7").Select

        ActiveSheet.Paste

        Application.CutCopyMode = False

        Selection.AutoFill Destination:=Range("Z7:AF506")

    End Sub

    Besides, what do you mean "Join it with other button"?

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by NicoPer Monday, November 28, 2016 6:04 PM
    Monday, November 28, 2016 9:56 AM
    Moderator
  • Cool, it worked. Thanks so much Celeste.
    Monday, November 28, 2016 6:05 PM