Highlight range of cells if one cell contains certain data

bamaisgreat

Well-known Member
Joined
Jan 23, 2012
Messages
831
Office Version
  1. 365
Platform
  1. Windows
I was wandering if the code below could be changed in a way where if the target had G4496-9809 it would still highlight.
Also if it could highlight the entire row instead of just the one cell. Thanks Jamey


Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Value = "[COLOR=#FF0000]G4496" T[/COLOR]hen Target.Interior.ColorIndex = 3
If Target.Value = "G4222" Then Target.Interior.ColorIndex = 4
If Target.Value = "G4276" Then Target.Interior.ColorIndex = 6
End Sub
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
before
This is the code below that is executed by a button on the 1st sheet

Sub RED_BUTTON()
'
ActiveSheet.Unprotect
'
'
Range("J7:N7").Select
ActiveCell.FormulaR1C1 = "BURN"
ActiveWorkbook.Save


NR = Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Row + 1

Sheets("Sheet2").Range("A" & NR).Value = Sheets("BURN").Range("B5").Value
Sheets("Sheet2").Range("B" & NR).Value = Sheets("BURN").Range("J4").Value
Sheets("Sheet2").Range("C" & NR).Value = Sheets("BURN").Range("B7").Value
Sheets("Sheet2").Range("D" & NR).Value = Sheets("BURN").Range("J5").Value
Sheets("Sheet2").Range("E" & NR).Value = Sheets("BURN").Range("B6").Value
Sheets("Sheet2").Range("F" & NR).Value = Sheets("BURN").Range("J6").Value
Sheets("Sheet2").Range("G" & NR).Value = Sheets("BURN").Range("L16").Value
Sheets("Sheet2").Range("H" & NR).Value = Sheets("BURN").Range("C10").Value

Range("P7:R10").Select
ActiveCell.FormulaR1C1 = "BURNEY"
Range("P7:R10").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255

Application.Wait Now + TimeSerial(0, 0, 1)

End With
Range("P11:R14").Select
ActiveCell.FormulaR1C1 = "PRINTING"

With Selection.Font
.Name = "Calibri"
.Size = 32
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorLight1
.ThemeFont = xlThemeFontMinor

Application.Wait Now + TimeSerial(0, 0, 1)

End With
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255

End With

Range("C10:N10").Select
ActiveWorkbook.Save
Range("P7:R14").Select
Selection.ClearContents

With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
ActiveWorkbook.Save

Range("C10").Select
Selection.ClearContents
Range("J7:N7").Select
Selection.ClearContents

ActiveSheet.Protect


Range("C10").Select
Selection.ClearContents
Range("J7:N7").Select
Selection.ClearContents

ActiveSheet.Protect
End Sub
 
Upvote 0
I'm assuming this is the part you're referring to:

Code:
Sheets("Sheet2").Range("A" & NR).Value = Sheets("BURN").Range("B5").Value
Sheets("Sheet2").Range("B" & NR).Value = Sheets("BURN").Range("J4").Value
Sheets("Sheet2").Range("C" & NR).Value = Sheets("BURN").Range("B7").Value
Sheets("Sheet2").Range("D" & NR).Value = Sheets("BURN").Range("J5").Value
Sheets("Sheet2").Range("E" & NR).Value = Sheets("BURN").Range("B6").Value
Sheets("Sheet2").Range("F" & NR).Value = Sheets("BURN").Range("J6").Value
Sheets("Sheet2").Range("G" & NR).Value = Sheets("BURN").Range("L16").Value
Sheets("Sheet2").Range("H" & NR).Value = Sheets("BURN").Range("C10").Value

which sets just the value, not the formats. So change each line's value sync to a copy/paste operation, e.g:

Sheets("BURN").Range("B5").copy destination:= Sheets("Sheet2").Range("A" & NR)
 
Upvote 0

Forum statistics

Threads
1,223,714
Messages
6,174,055
Members
452,542
Latest member
Bricklin

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