Results 1 to 5 of 5

Thread: how to change colour of cell if anything is entered in textbox
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Feb 2018
    Location
    Midlands, UK
    Posts
    678
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

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

    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

  2. #2
    MrExcel MVP
    Moderator

    Tracy's new best bud
    Jon von der Heyden's Avatar
    Join Date
    Apr 2004
    Location
    London, UK
    Posts
    10,657
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    4 Thread(s)

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

    You could check that the length of the text in the TextBox is not 0:

    Code:
    If Len(TextBox14.Value) Then
    Regards,
    Jon von der Heyden

    Posting guidelines | Forum rules | FAQs
    English is a weird language. It can be understood through tough thorough thought, though!

  3. #3
    Board Regular
    Join Date
    Feb 2018
    Location
    Midlands, UK
    Posts
    678
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

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

    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

  4. #4
    MrExcel MVP
    Moderator

    Tracy's new best bud
    Jon von der Heyden's Avatar
    Join Date
    Apr 2004
    Location
    London, UK
    Posts
    10,657
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    4 Thread(s)

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

    Howdy

    Remove the = ""
    Code:
    If Len(TextBox14.value) = "" Then
    Regards,
    Jon von der Heyden

    Posting guidelines | Forum rules | FAQs
    English is a weird language. It can be understood through tough thorough thought, though!

  5. #5
    Board Regular
    Join Date
    Feb 2018
    Location
    Midlands, UK
    Posts
    678
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

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

    that is great thank you for your help, works a treat

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •