none
Excel VBA RRS feed

  • Question

  • Can anyone help me with vba code please?

    I'm in cell A1

    I call up the macro

    If the font colour in the cell is RED, change it to Automatic (Black)

    If the font colour is Black (automatic), change it to RED.

    (The code I am using for RED is -16776961)

    Any advice would be appreciated

    Saturday, December 8, 2018 12:34 PM

All replies

  • Try this:

    Sub ChangeColor()
        With ActiveCell.Font
            Select Case .Color
                Case vbBlack
                    .Color = vbRed
                Case vbRed
                    .Color = vbBlack
                Case Else
                    ' Do nothing?
            End Select
        End With
    End Sub


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Saturday, December 8, 2018 2:25 PM
  • Hi,

    This is the forum to discuss questions and feedback for Microsoft Excel features, 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. Thank you for your understanding.

    Regards,

    Emi


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Monday, December 10, 2018 2:57 AM
  • Hi jams,

    Did Hans's answer resolved your problem?
    You can mark it as answer if it helped and please help us close the thread.

    Best Regards,

    Yuki


    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.

    Tuesday, December 11, 2018 3:08 AM
    Moderator