excelbytes
Active Member
- Joined
- Dec 11, 2014
- Messages
- 291
- Office Version
- 365
- Platform
- Windows
I am new to VBA. I am trying to change the background color of a text box based on another cell value. I am getting a Runtime error 424 Object required error. Here is my code - what am I doing wrong?
Public Sub TextBoxColor()
If Worksheets("Sheet1").Range("E1").Value = "Name" Then
TextBox1.Interior.ColorIndex = 3
ElseIf Worksheets("Sheet1").Range("E1").Value = "Blog" Then
TextBox1.Interior.ColorIndex = 10
ElseIf Worksheets("Sheet1").Range("E1").Value = "Help" Then
TextBox1.Interior.ColorIndex = 20
End If
End Sub
Public Sub TextBoxColor()
If Worksheets("Sheet1").Range("E1").Value = "Name" Then
TextBox1.Interior.ColorIndex = 3
ElseIf Worksheets("Sheet1").Range("E1").Value = "Blog" Then
TextBox1.Interior.ColorIndex = 10
ElseIf Worksheets("Sheet1").Range("E1").Value = "Help" Then
TextBox1.Interior.ColorIndex = 20
End If
End Sub