Find and replace all in column

aurelius89

Board Regular
Joined
Mar 15, 2017
Messages
69
In a column, I want to replace all the "o" with "0"

This would be easy however the "o" could be part of other text in the cell, I don't want to replace ALL the cell with "0", only when it finds "o"

e.g - B1o becomes B10

I have found something like this, where within the Loop I could use REPLACE instead of what they have here:
Code:
Sub Test()
    Dim Rng As Range
    Dim c As Range
    Dim Length As Integer
    Dim LeftSide As Integer
    Dim RightSide As Integer
    Set Rng = Range("D6:D" & Range("D65536").End(xlUp).Row)
    For Each c In Rng
        LeftSide = InStr(c, "|")
        RightSide = InStr(LeftSide + 1, c, "|")
        Length = RightSide - LeftSide
        If Length > 0 Then
            c.Characters(Start:=LeftSide, Length:=Length).Font.FontStyle = "Bold"
        End If
    Next c
End Sub

However, adding another loop to my already extensive code is going to slow it down even more.

I was wondering if there was a simpler/better way to achieve this?

Many Thanks
 
Last edited:

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Does this work (loop only shown)?

Code:
    For Each c In Rng
        c = Replace ( c, "o", "O")
    Next c
 
Upvote 0
Without looping you could try something like this:

Code:
Range("D6:D" & Rows.Count).Replace What:="o", Replacement:="0", LookAt:=xlPart, MatchCase:=False
 
Upvote 0

Forum statistics

Threads
1,214,622
Messages
6,120,580
Members
448,972
Latest member
Shantanu2024

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