excel vba - how to change text font when "If" statement runs

  • Thread starter Thread starter chief
  • Start date Start date
C

chief

I am wondering if it's possible to have text font return to automati
(black) when someone enters their name in my password textbox an
clicks OK.

Here's the layout. I have a userform set up ("Password") which runs o
workbook_open. When it comes up the person must enter their name i
Textbox1 and click OK in order to view the page. In rows D and E, th
text has been manually selected as white in order to hide the contents
Is there a way to set up a code in the Password userform so that:

Private Sub CommandButton1_Click()
If Textbox1.Text = "Mike" Then
Sheet1.Range("D1:E400").Value = (Font color Automatic Black?)
ElseIf Textbox1.Text = "Jen" Then
Sheet1.Range("D1:E500").Value = (Font color White?)
End If
End Sub

Does that make sense, and can it be done
 
Private Sub CommandButton1_Click()
If Textbox1.Text = "Mike" Then
Sheet1.Range("D1:E400").Font.ColorIndex = 1
ElseIf Textbox1.Text = "Jen" Then
Sheet1.Range("D1:E500").Font.ColorIndex = 2
End If
End Sub


Keep one thing in mind though....Even with white as your font color
the text still may be able to be read if the user was to either selec
all the cells on the sheet or select a range of cells that contain you
"hidden" text. This is due to the fact that when a range of cells i
selected, the selection range appears with a light blue background
allowing the white font to be seen. In addition to this, the text ma
also be able to be seen in the formula bar along the top if one of th
cells containing the "hidden" text was selected.



Rolli
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top