with Specific text in a row format the whole row in to Red

hsolanki

Board Regular
Joined
Jan 16, 2020
Messages
204
Office Version
  1. 2010
Platform
  1. Windows
Hi everyone I have an userform whereby user enters all the information from Userform including selects their names from combobox1 and transfers on to the sheets however i was wondering if there is any way that when user selects thier name and trasnfer the data on to the sheer and if specific text was found then all of that should format into Red Fonts

e.g. specific text would be like their Names. e.g "Name 1", "Name 2" and "Name 3" and Name 4 should stay as it is
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Yes - this would be a validation rule to find identical values and then you can do a conditional formatting rule based on if validation is true.
 
Upvote 0
Hi can these be archived by vba code to highlight the red colour of whole row value if specified value was selected?
 
Upvote 0
Hi i have found below code and tweeted a little however it only change the color of one column in a row rather changing the whole rows value.

VBA Code:
Dim r As Range: Set r = Range("D1:D" & Range("D" & Rows.Count).End(xlUp).Row) 
Dim crit As Variant: crit = Array("Name1", "Name3") 
Dim cel As Range
Dim pos As Integer

For Each cel In r
    For i = 0 To UBound(crit)
        pos = InStr(cel.Value, crit(i))
        If pos > 0 Then
            cel.Characters(pos, Len(crit(i))).Font.Color = vbRed
        End If
    Next i
Next cel
 
Upvote 0
Hi Sorry i have found below code and it works with one name however when i tried below with multi names i get an error

VBA Code:
Const TEST_COLUMN As String = "D"
Dim LastRow As Long
Dim cell As Range
sSheetName = ActiveSheet.Name

With Worksheets(sSheetName)
LastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row

For Each cell In Range("D6:D" & LastRow)
If cell.Value = "Name 1" Or "Name 2" Or "Name 3" Then
cell.EntireRow.Font.Color = vbRed
ElseIf cell.Value = "" Then
cell.EntireRow.Interior.ColorIndex = 43
Else
cell.EntireRow.Interior.ColorIndex = xlNone
End If
Next
End With
 
Upvote 0

Forum statistics

Threads
1,212,928
Messages
6,110,737
Members
448,295
Latest member
Uzair Tahir Khan

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