how to change colour of cell if anything is entered in textbox

Patriot2879

Well-known Member
Joined
Feb 1, 2018
Messages
1,259
Office Version
  1. 2010
Platform
  1. Windows
Hello :), good morning all. Just wondering f you can help please. I have the code below, but this time I want the row to change colour if anything is entered into the textbox so not word specific I have tried for the TextBox14 value "" and "*" but that didn't work, please can you advise.

Code:
Private Sub TextBox14_Change()
  With ThisWorkbook.Sheets("Sheet1")
  emptyRow = .Cells(Rows.Count, "O").End(xlUp).Row + 1
    If TextBox14.value = "" Then Range(.Cells(emptyRow, 1), .Cells(emptyRow, 18)).Interior.Color = RGB(200, 0, 0)

  End With
End Sub
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
You could check that the length of the text in the TextBox is not 0:

Code:
If Len(TextBox14.Value) Then
 
Upvote 0
hi just adapted to the code below but still didn't work, hope you can advise please? whats needed is for the background to change colour no matter what is entered into the textbox14

Code:
Private Sub TextBox14_Change()
  With ThisWorkbook.Sheets("Sheet1")
  emptyRow = .Cells(Rows.Count, "O").End(xlUp).Row + 1
    If Len(TextBox14.value) = "" Then Range(.Cells(emptyRow, 1), .Cells(emptyRow, 18)).Interior.ColorIndex = 37

  End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,952
Messages
6,175,593
Members
452,654
Latest member
mememe101

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top