Macro to format row if a certain value is enetered into a cell

Reneek

New Member
Joined
Jun 21, 2011
Messages
24
hi there

I am after a macro that will run automatically when I enter the value of "NV" (abbreviation for "no longer valid") into the column W.

I would like it to then highlight that row and format the text with a strikethrough and change the font colour to dark grey.

The value of NV is selected by a drop down box.

Can anyone help?

Thanks in advance.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Right click on the sheet name --> view code
then paste this code
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 23 Then Exit Sub
If Target.Value = "NV" Then
    With Range(Cells(Target.Row, 1), Cells(Target.Row, 23))
        .Select
        .Font.Strikethrough = True
        .Interior.ColorIndex = 7 'change the color index as you want
    End With
End If
End Sub
 
Upvote 0
Welcome to the Board!

Why use VBA when you can do all of that with Conditional Formatting? Plus you won't have to add to the code in case you want to change NV to something else.

HTH,
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,292
Members
452,902
Latest member
Knuddeluff

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