VBA Excel Find Specific Text in table and Change Font Color

sanityendshere

New Member
Joined
Aug 7, 2020
Messages
7
Office Version
  1. 365
Platform
  1. Windows
Hey everyone,

I am producing tables from a database that can contain multiple pages of data. One of the report requirements is to change ND to silver or -0349986266670736. I know I could technically do all of this with conditional formatting; however, I have written VBA for all of the other table formattings and was hoping I could add code to change ND to the silver color. I've been looking online and have been unsuccessful to find code that will work for what I need. Is this even possible? If so, will someone help me out with the code for this particular instance? Thanks in advance for any help you can provide.
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Sorry .. what is ND ?

Are you wanting to change the FONT COLOR or the cell INTERIOR COLOR ?

Post your existing code.
 
Upvote 0
How about
VBA Code:
Sub sanityendshere()
   With Application.ReplaceFormat
      .Clear
      .Font.Color = rgbSilver
   End With
   Range("A2:I100").Replace "ND", "ND", xlWhole, , False, , False, True
   Application.ReplaceFormat.Clear
End Sub
 
Upvote 0
Please bare with me as I'm very new to VBA and couldn't find my answer in any of the other posts. We use ND to represent when values were non-detect during analysis. Our client would like them to be silver so detected values stand out more in the table. I am hoping to automate this because some of our tables can be 10+ pages.

ND.png


The code I currently have is:

Sheets(j).Range("C7:" & LastColName & "24").Select
Range("C7:" & LastColName & "24").Activate
With Selection.ReplaceFormat
.ThemeColor = xlThemeColorDark1
.TintAndShade = -0.349986266670736
Sheets(j).Range("C7:" & LastColName & "24").Replace "ND", "ND", xlWhole, , False, , False, True
Selection.ReplaceFormat.Clear
End With
 
Upvote 0
Did you try the code I posted?
 
Upvote 0
@Fluff I just tried your code and it works! Thank you so much. I think I was trying to make it too difficult with my ranges. THank you!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,858
Members
449,051
Latest member
excelquestion515

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