change colour of whole row dependant on cell value

Patriot2879

Well-known Member
Joined
Feb 1, 2018
Messages
1,259
Office Version
  1. 2010
Platform
  1. Windows
Hi good morning, hope you can help. I have the code below where if OOH is in a cell I want the whole row to change colour, but the code below is not working, hope you can help?

Code:
Private Sub Highlight()
Dim col As Range
Dim value(0) As Integer
Worksheets("Sheet1").Activate
Set col = Range("H5:h")
If col.value = OOH Then
ActiveSheet.Row.Select
With Selection.Interior
.Color = -19125255
.Font.Bold = True
        End With
                    End If
    End Sub
 
Re: change colur of whole row dependant on cell value help

Hi,

Have a go with following ...

Code:
Private Sub ComboBox6_Change()
  With ThisWorkbook.Sheets("Handover")
     emptyRow = .Cells(Rows.Count, "H").End(xlUp).Row + 1
    If ComboBox6.Value = "OOH" Then Range(.Cells(emptyRow, 1), .Cells(emptyRow, 12)).Interior.Color = -19125255
  End With
End Sub
 
Last edited:
Upvote 0

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Re: change colur of whole row dependant on cell value help

hiya thankyou again for the help I have put in the code below, but I am getting an error on the range it is highlighted in yellow
Code:
Private Sub ComboBox6_Change()
  With ThisWorkbook.Sheets("Sheet1")
    If ComboBox6.value = "OOH" Then Range(.Cells(emptyRow, 1), .Cells(emptyRow, 12)).Interior.Color = -19125255
  End With
End Sub
 
Upvote 0
Re: change colur of whole row dependant on cell value help

The error comes up as soon as I put OOH in my dropdown box (ComboBox6) in my userform when I am filling it in, hope you can help? :) thank you again for your time.
 
Upvote 0
Re: change colur of whole row dependant on cell value help

I don't know if this makes a difference but the row will go from A to N if that makes a difference with the code?
 
Upvote 0
Re: change colur of whole row dependant on cell value help

Please refer to my message # 11 ...

Within the code ... you do need to define the row ... which you are calling ' emptyrow '

Code:
[COLOR=#333333]emptyRow = .Cells(Rows.Count, "H").End(xlUp).Row + 1[/COLOR]
 
Upvote 0
Re: change colur of whole row dependant on cell value help

hi thanks, how would I add that into the code below? sorry with all the issues, I am still new to this and learning. Row H is the cell where 'OOH' will be and the row A-N is what I want to be coloured in.

Code:
Private Sub ComboBox6_Change()
  With ThisWorkbook.Sheets("Sheet1")
    If ComboBox6.value = "OOH" Then Range(.Cells(emptyRow, 1), .Cells(emptyRow, 12)).Interior.Color = -19125255
  End With
End Sub
 
Last edited:
Upvote 0
Re: change colur of whole row dependant on cell value help

Again... for your TEST ...

Why don't you simply Copy exactly ...the SIX instructions in message # 11 ... ???
 
Upvote 0
Re: change colur of whole row dependant on cell value help

:) I did it thank you:) phew finally.... thanks for the advise again
 
Upvote 0
Re: change colur of whole row dependant on cell value help

You are welcome ... :wink:
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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