none
Expand / fill selected area with macro objects RRS feed

  • Question

  • I have a few rows of active macros that I wanted to fill / copy for new rows on the same sheet where the macros then automatically adapted to the new rows.
    Possibly by click CommandButton1 (billed) marks and changes the background color of the cell range A1: S2, I would like to do with several similar "billed" buttons on the new cell areas, eg. A3: S4, A5: S6 etc. Can this be done and how?

    Hope someone can help, or just someone who can say that it is not possible.
    Tuesday, January 10, 2017 8:44 AM

All replies

  • Hi BoHermansen,

    This is the forum to discuss questions and feedback for Microsoft Excel client, as it seems that your query is more related to developing issues involving Excel, I'll move your question to the MSDN forum for Excel:

    https://social.msdn.microsoft.com/Forums/en-US/home?forum=exceldev

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us.

    Thanks for your understanding:)

    Best regards,
    Yuki Sun


    Please remember to mark the replies as answers if they helped.

    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Wednesday, January 11, 2017 6:45 AM
  • Hi,

    We could use selection object to refer the selected range.

    For more information, please visit Working with the Selection Object

    For example, to change the background color for selected range, we could use:

    Sub Macro1()
        With Selection.Interior
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .Color = 65535
            .TintAndShade = 0
            .PatternTintAndShade = 0
        End With
    End Sub

    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.

    Friday, January 13, 2017 5:09 AM
    Moderator