Stephen_IV
Well-known Member
- Joined
- Mar 17, 2003
- Messages
- 1,177
- Office Version
- 365
- 2019
- Platform
- Windows
I have some code below and it works fine for most of the data sets that I have. The problem is that I have data that is put into a cell using Ctrl+ Enter or Char(10). i need to update the code to handle Chr(10). Can Someone please assist me.
Thanks in Advance.
The table below does not show the Char(10) but this is what the data looks like.
<style type="text/css">
table.tableizer-table {
font-size: 12px;
border: 1px solid #CCC ;
font-family: Arial, Helvetica, sans-serif;
}
.tableizer-table td {
padding: 4px;
margin: 3px;
border: 1px solid #CCC ;
}
.tableizer-table th {
background-color: #104E8B ;
color: #FFF ;
font-weight: bold;
}
</style>
<table class="tableizer-table">
<thead><tr class="tableizer-firstrow"><th>Course</th></tr></thead><tbody>
<tr><td>STEM LAB III [1] (13)</td></tr>
<tr><td>"US HISTORY [4] (2)</td></tr>
<tr><td>PERSPECTIVES ON RACE [4] (3)</td></tr>
<tr><td>WORLD CIVILIZATION [10] (4)"</td></tr>
<tr><td>HEALTH [16] (24)</td></tr>
<tr><td>"PHYSICAL SCIENCE [2] (5)</td></tr>
<tr><td>ENVIRONMENTAL SCIENCE [9] (3)"</td></tr>
</tbody></table>
Thanks in Advance.
The table below does not show the Char(10) but this is what the data looks like.
<style type="text/css">
table.tableizer-table {
font-size: 12px;
border: 1px solid #CCC ;
font-family: Arial, Helvetica, sans-serif;
}
.tableizer-table td {
padding: 4px;
margin: 3px;
border: 1px solid #CCC ;
}
.tableizer-table th {
background-color: #104E8B ;
color: #FFF ;
font-weight: bold;
}
</style>
<table class="tableizer-table">
<thead><tr class="tableizer-firstrow"><th>Course</th></tr></thead><tbody>
<tr><td>STEM LAB III [1] (13)</td></tr>
<tr><td>"US HISTORY [4] (2)</td></tr>
<tr><td>PERSPECTIVES ON RACE [4] (3)</td></tr>
<tr><td>WORLD CIVILIZATION [10] (4)"</td></tr>
<tr><td>HEALTH [16] (24)</td></tr>
<tr><td>"PHYSICAL SCIENCE [2] (5)</td></tr>
<tr><td>ENVIRONMENTAL SCIENCE [9] (3)"</td></tr>
</tbody></table>
Code:
Sub InsideBrackets()
Dim x As Long
Dim y As Long
Dim xcell As Range
Dim lastrow As Long
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
For Each xcell In Range("B2:H" & lastrow)
x = InStr(xcell.Value, "(")
y = InStr(xcell.Value, ")")
xcell.Characters(x + 1, y - 1 - x).Font.ColorIndex = 3
Next xcell
End Sub