Changing the colour of characters

RyanChristy

New Member
Joined
Aug 30, 2011
Messages
11
Dear all,

I had previously asked for help for a vba to remove the underscores in all cells within a range.

I was given this code as a module:

Option Explicit
Sub FixUnderscores()
Dim USFound As Range
Dim FirstAddress As String
Dim Pos As Long

With Sheets("Live Report").Range("B203:I242")
Set USFound = .Find(What:="_", LookIn:=xlValues, _
LookAt:=xlPart, SearchFormat:=False)
If Not USFound Is Nothing Then
FirstAddress = USFound.Address
Do
With USFound
Pos = InStr(1, .Value, "_")
Do
.Characters(Start:=Pos, Length:=1) _
.Font.Color = .Interior.Color
Pos = InStr(Pos + 1, .Value, "_")
Loop While Pos > 0
End With
Set USFound = .FindNext(After:=USFound)
Loop While USFound.Address <> FirstAddress
End If
End With
End Sub


And I was given this code to run on the sheet:

Private Sub Worksheet_Change(ByVal Target As Range)
Const CheckRanges As String = ("B280:I319")

If Not Intersect(Target, Range(CheckRanges)) Is Nothing Then
FixUnderscores
End If
End Sub

It did work, however I have made some changes to the sheet and now it refuses to work.

I have done everything I can think of to edit but I'm having no luck, could anyone help me please?

Many Thanks

Ryan Christy
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Apologies for wasting your time - The cell ranges don't match.
9 times out of 10 its the most obvious thing - I really should have looked before posting on here.

Sorry.

Ryan
 
Upvote 0

Forum statistics

Threads
1,224,595
Messages
6,179,798
Members
452,943
Latest member
Newbie4296

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