Results 1 to 6 of 6

Thread: colors command button, excel cell.

  1. #1
    Acolyte Heyjoe's Avatar
    Join Date
    Jan 2019
    Location
    USA
    Posts
    55
    Articles
    0
    Excel Version
    2019

    colors command button, excel cell.



    Register for a FREE account, and/
    or Log in to avoid these ads!

    I took a cell on a worksheet and changed the background color. I recorded a macro while I did this. You see in the macro that the cell background color is 10092543.

    Sub Macro2()
    '
    ' Macro2 Macro
    '


    '
    With Selection.Interior
    .Pattern = xlSolid
    .PatternColorIndex = xlAutomatic
    .Color = 10092543
    .TintAndShade = 0
    .PatternTintAndShade = 0
    End With
    End Sub

    The back color on my command button is &H00C0FFFF&.

    How do I get the backcolor on the cell and the command button to be the same?

  2. #2
    Administrator Pecoflyer's Avatar
    Join Date
    Oct 2011
    Location
    Brussels Belgium
    Posts
    1,679
    Articles
    0
    Excel Version
    2010 on Xubuntu
    Hi,
    When posting code, please wrap it with code tags ( Edit code - select code - click the #button.)
    It keeps the macro's structure and makes it easy to copy and handle.
    Thank you
    Thank you Ken for this secure forum.

  3. #3
    Magician NoS's Avatar
    Join Date
    Jan 2013
    Location
    British Columbia
    Posts
    769
    Articles
    0
    Excel Version
    Excel 2010 64bit
    Code:
        .Color = CommandButton1.BackColor

  4. #4
    Acolyte Heyjoe's Avatar
    Join Date
    Jan 2019
    Location
    USA
    Posts
    55
    Articles
    0
    Excel Version
    2019
    Using your code I get run-time error '424'
    Object required.

  5. #5
    Magician NoS's Avatar
    Join Date
    Jan 2013
    Location
    British Columbia
    Posts
    769
    Articles
    0
    Excel Version
    Excel 2010 64bit
    try
    Code:
        .Color = ActiveSheet.CommandButton1.BackColor

  6. #6
    Acolyte Heyjoe's Avatar
    Join Date
    Jan 2019
    Location
    USA
    Posts
    55
    Articles
    0
    Excel Version
    2019
    Thank you all for your help.

    I ended up with the following code:

    Code:
    Public Sub cc()
    
    
    Range("D10").Interior.Color = ActiveSheet.CommandButton1.BackColor
    
    
    End Sub
    You must color the backcolor of the command button by using palette in order for this code to work. If you color it using system, cell d10 will be black.

Posting Permissions

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