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

hsolanki

Board Regular
Joined
Jan 16, 2020
Messages
124
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
 

Some videos you may like

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Krayna

New Member
Joined
Feb 2, 2021
Messages
33
Office Version
  1. 365
Platform
  1. Windows
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.
 

hsolanki

Board Regular
Joined
Jan 16, 2020
Messages
124
Office Version
  1. 2010
Platform
  1. Windows
Hi can these be archived by vba code to highlight the red colour of whole row value if specified value was selected?
 

hsolanki

Board Regular
Joined
Jan 16, 2020
Messages
124
Office Version
  1. 2010
Platform
  1. Windows
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
 

hsolanki

Board Regular
Joined
Jan 16, 2020
Messages
124
Office Version
  1. 2010
Platform
  1. Windows
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
 

Watch MrExcel Video

Forum statistics

Threads
1,127,379
Messages
5,624,351
Members
416,022
Latest member
JonathanSass

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
Top