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
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