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

Patriot2879

Well-known Member
Joined
Feb 1, 2018
Messages
1,227
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

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
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,214,376
Messages
6,119,178
Members
448,871
Latest member
hengshankouniuniu

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