Download free Excel Macro : Highlight Specific Text
Macros are one of the most powerful features in Excel. They are small programs that can automate tasks and save you a lot of time.
If you are not familiar with macros, they can seem a bit daunting. But once you learn how to use them, you will wonder how you ever managed without them!
In this article, we will show you how to use the Macro "Highlight Specific Text" in Excel. We will also provide some examples of how macros can be used to automate tasks.
How to use Macros in Excel?
Macros are written in a programming language called Visual Basic for Applications (VBA). VBA is a simple language that is easy to learn.
You do not need to be a programmer to use macros. However, if you are familiar with programming, you can use VBA to create more complex macros.
There are two ways to use macros in Excel:
1. Use a macro that is already written.
2. Write your own macro.
For both methods check out those articles to know how to use macros in Excel:
To create a macro in Excel, open the Visual Basic Editor (VBE) by pressing Alt+F11 on your keyboard.
In the VBE, select Insert > Module. This will insert a new blank module into the VBE.
In the new module, paste the code below.
For example, the following code will create a macro that will Highlight Specific Text:
Sub highlightValue() Dim myStr As String Dim myRg As range Dim myTxt As String Dim myCell As range Dim myChar As String Dim I As Long Dim J As Long On Error Resume Next If ActiveWindow.RangeSelection.Count > 1 Then myTxt = ActiveWindow.RangeSelection.AddressLocal Else myTxt = ActiveSheet.UsedRange.AddressLocal End If LInput: Set myRg = _ Application.InputBox _ ("please select the data range:", "Selection Required", myTxt, , , , , 8) If myRg Is Nothing Then Exit Sub If myRg.Areas.Count > 1 Then MsgBox "not support multiple columns" GoTo LInput End If If myRg.Columns.Count <> 2 Then MsgBox "the selected range can only contain two columns " GoTo LInput End If For I = 0 To myRg.Rows.Count - 1 myStr = myRg.range("B1").Offset(I, 0).Value With myRg.range("A1").Offset(I, 0) .Font.ColorIndex = 1 For J = 1 To Len(.Text) Mid(.Text, J, Len(myStr)) = myStrThen .Characters(J, Len(myStr)).Font.ColorIndex = 3 Next End With Next I End Sub
To run the macro, press the Run button in the toolbar (or press F5 on your keyboard).
About Highlight Specific Text Excel Macro
If you work with a lot of data in Excel, you know how frustrating it can be to try and find a specific piece of information. Whether you're looking for a customer's name or a product ID, scrolling through endless rows of data is not an efficient way to find what you need. Luckily, there is a way to quickly find the information you're looking for in Excel. By using the "Highlight Specific Text" Excel macro, you can quickly and easily search for specific text in your data set. To use the macro, simply enter the text you're looking for in the "Search for" field. Then, click the "Search" button. The macro will then highlight all of the cells that contain