Hello!
First time posting here, this site has been very helpful for me while at work, however I am stuck on a bit of VBA code that I hope someone doesn't mind helping me with.
*Note* I'm VERY new to VBA, and really with coding in general. Have SQL experience but that's about it....so please keep this in mind!
Scenario:
I have 13 ActiveX Text Boxes in a Spreadsheet. When the value is empty, they display gray text (Textbox1_Lostfocus).. When a box is selected (Textbox1_GotFocus), the text value automatically clears. When a user types a Number or Value (depending on the particular text box), the text becomes black.
TextBox1 contains only numbers EX: "00000000". Text Boxes 2-4 contain "####", and text boxes 5-13 contain "YYYY-MM-DD".
Currently, I have the following for EACH Text Box:
It works, but as you could imagine....it's not very efficient. I tried all day to get this piece of VBA code consolidated into a Loop of sorts (Once again, very new to all of this) based on the text values (EX: Text Boxes 2-4 contain "####), but couldn't figure it out.
Any help would be greatly appreciated! Also, please include the Subs if possible.
First time posting here, this site has been very helpful for me while at work, however I am stuck on a bit of VBA code that I hope someone doesn't mind helping me with.
*Note* I'm VERY new to VBA, and really with coding in general. Have SQL experience but that's about it....so please keep this in mind!
Scenario:
I have 13 ActiveX Text Boxes in a Spreadsheet. When the value is empty, they display gray text (Textbox1_Lostfocus).. When a box is selected (Textbox1_GotFocus), the text value automatically clears. When a user types a Number or Value (depending on the particular text box), the text becomes black.
TextBox1 contains only numbers EX: "00000000". Text Boxes 2-4 contain "####", and text boxes 5-13 contain "YYYY-MM-DD".
Currently, I have the following for EACH Text Box:
Code:
Private Sub Textbox2_Lostfocus()
If Me.TextBox1.Value = "" Then
Me.TextBox1.Value = "####"
End If
If Me.TextBox1.Value = "####" Then
Me.TextBox1.ForeColor = RGB(100, 100, 50)
End If
End Sub
-------------------------------------------------
Private Sub Textbox2_Gotfocus()
If Me.TextBox1.Value = "####" Then
Me.TextBox1.Value = ""
End If
If Me.TextBox1.Value = "" Then
Me.TextBox1.ForeColor = RGB(0, 0, 0)
End If
End Sub
It works, but as you could imagine....it's not very efficient. I tried all day to get this piece of VBA code consolidated into a Loop of sorts (Once again, very new to all of this) based on the text values (EX: Text Boxes 2-4 contain "####), but couldn't figure it out.
Any help would be greatly appreciated! Also, please include the Subs if possible.