Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7690181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:20:13+00:00 2026-05-31T20:20:13+00:00

In excel I have to search for specific word in a cell and replace

  • 0

In excel I have to search for specific word in a cell and replace only that the particular word.

For example:
In excel a cell may contain

“team should have loaded test data into the file”

I want to select only a single word in this line such as test and apply a style to that particular string

“team should have loaded test data into the file”

I have many cells to format so I would like to use VBA

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T20:20:14+00:00Added an answer on May 31, 2026 at 8:20 pm

    Something like this will change “test” in all cells in a user selected range to bold. It handles multiple occurrences in a single cell

    The test is case insensitive

    Option Explicit
    
    Const strText As String = "test"
    
    Sub ColSearch_DelRows()
    Dim rng1 As Range
    Dim rng2 As Range
    Dim cel1 As Range
    Dim cel2 As Range
    Dim strFirstAddress As String
    Dim lAppCalc As Long
    Dim objRegex As Object
    Dim RegMC As Object
    Dim RegM As Object
    
    Set objRegex = CreateObject("vbscript.regexp")
    
    With objRegex
        .Global = True
        .Pattern = strText
    End With
    
    'Get working range from user
    On Error Resume Next
    Set rng1 = Application.InputBox("Please select range to search for " & strText, "User range selection", Selection.Address(0, 0), , , , , 8)
    On Error GoTo 0
    If rng1 Is Nothing Then Exit Sub
    
    With Application
        lAppCalc = .Calculation
        .ScreenUpdating = False
        .Calculation = xlCalculationManual
    End With
    
    Set cel1 = rng1.Find(strText, , xlValues, xlPart, xlByRows, , False)
    If Not cel1 Is Nothing Then
        Set rng2 = cel1
        strFirstAddress = cel1.Address
        Do
            Set cel1 = rng1.FindNext(cel1)
            Set rng2 = Union(rng2, cel1)
        Loop While strFirstAddress <> cel1.Address
    End If
    
    If Not rng2 Is Nothing Then
        For Each cel2 In rng2
            Set RegMC = objRegex.Execute(cel2.Value)
            For Each RegM In RegMC
                cel2.Characters(RegM.firstindex, RegM.Length + 1).Font.Bold = True
            Next
        Next
    End If
    
    With Application
        .ScreenUpdating = True
        .Calculation = lAppCalc
    End With
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an excel file that i need to open and search it. This
I have Excel add-in which I add so many class modules that it is
In Excel I have attached a picture to a cell using the following Sub
is there a way in Excel to have a formula that does something like
I am importing massive amounts of data from Excel that have various table layouts.
We have an Excel 2002/XP based application that interacts with SQL 2000/5 to process
I have the following scenario that may warrant storing data in a conroller member
I have an application in turbogears that dynamically generates an excel spreadsheet, meaning it
I have .txt files that contain the output from a data logger. The data
I have column A B C D how to search in Excel (not csv)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.