Option button = true then font colour to be changed

  • Morning.
    when I run the command button on my Userform I would like the font colour to be applied to the YES / NO text that will be entered on my worksheet depending on which option button was selected.

    So on the Userform if option button 12 is selected I would like the text to be Red BUT if option button 13 is selected then the text should be Green.



  • I understand that but i would like to use VBA


    The code in place shown below would be the start of it but not sure how to write it


    Code
    1. If OptionButton1.Value = True Then .Cells(8, 10).Value = "YES": OptionButton1.Value = False
    2. If OptionButton2.Value = True Then .Cells(8, 10).Value = "NO": OptionButton2.Value = False
  • Try this


    Code
    1. If OptionButton1.Value = True Then
    2. .Cells(8, 10).Value = "YES"
    3. .Cells(8, 10).Interior.ColorIndex = vbRed
    4. OptionButton1.Value = False
    5. ElseIf OptionButton2.Value = True Then
    6. .Cells(8, 10).Value = "NO"
    7. .Cells(8, 10).Interior.ColorIndex = vbGreen
    8. OptionButton2.Value = False
    9. End If
  • Hi,


    Do i replace this.


    Code
    1. If OptionButton1.Value = True Then .Cells(8, 10).Value = "YES": OptionButton1.Value = False
    2. If OptionButton2.Value = True Then .Cells(8, 10).Value = "NO": OptionButton2.Value = False


    With this.

    Code
    1. If OptionButton1.Value = True Then
    2. .Cells(8, 10).Value = "YES"
    3. .Cells(8, 10).Interior.ColorIndex = vbRed
    4. OptionButton1.Value = False
    5. ElseIf OptionButton2.Value = True Then
    6. .Cells(8, 10).Value = "NO"
    7. .Cells(8, 10).Interior.ColorIndex = vbGreen
    8. OptionButton2.Value = False
    9. End If



    I ask because i then get subscript of range

  • crossposted: https://www.mrexcel.com/board/…rior-cell-advice.1128108/


    Your post does not comply with our Forum RULES. Do not cross-post your question on multiple forums without telling us about your threads on other forums.


    Post a link to any other forums where you have asked the same question.


    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.


    Go to https://www.excelguru.ca/content.php?184 to understand why we ask you to do this.


    I have added the crosspost reference for you today. Please comply with this and all our rules in the future