ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Highlighting part of a cell contents in Excel 2003 (https://www.excelbanter.com/excel-programming/406918-re-highlighting-part-cell-contents-excel-2003-a.html)

JLGWhiz

Highlighting part of a cell contents in Excel 2003
 
The following would change the 3rd and 4th characters of
a string to red font. If the characters are number data type,
this code fails.

Sub clrfnt()
Sheets(1).Range("A1").Characters(3, 2) _
.Font.ColorIndex = 3
End Sub


"Gregg" wrote:

I have values in cells A1:A10 expressed thusly: A1= 23_47
A2= 37_9
etc.. I would like to write code that will highlight individual
numbers in the cells A1:A10 that are greater than 32 and
less than 101. In cell A1 "47" would be highlighted, in cell
A2 "37" would be highlighted. Red can be the highlight color.
Gregg


Gregg

Highlighting part of a cell contents in Excel 2003
 
Thanks JLG, but I'm not sure how I could use your information in the example
I gave. I think a conditional for each loop of some sort might get the job
done
but I'm not sure.
--
Gregg


"JLGWhiz" wrote:

The following would change the 3rd and 4th characters of
a string to red font. If the characters are number data type,
this code fails.

Sub clrfnt()
Sheets(1).Range("A1").Characters(3, 2) _
.Font.ColorIndex = 3
End Sub


"Gregg" wrote:

I have values in cells A1:A10 expressed thusly: A1= 23_47
A2= 37_9
etc.. I would like to write code that will highlight individual
numbers in the cells A1:A10 that are greater than 32 and
less than 101. In cell A1 "47" would be highlighted, in cell
A2 "37" would be highlighted. Red can be the highlight color.
Gregg


JLGWhiz

Highlighting part of a cell contents in Excel 2003
 
Well, with a little imagination, I can visualize using an If Then statement
to set the conditions you mention and for every item that meets that
conditon, set the Characters function to select the part of the string you
want to highlight. The only thing is, that using this method, you would have
to have a consisten pattern like
Characters(4, 3) which would start at the fourth character from the left and
apply to three consecutive characters. But you cannot use it if the pattern
will vary in starting point or length to be applied.

"Gregg" wrote:

Thanks JLG, but I'm not sure how I could use your information in the example
I gave. I think a conditional for each loop of some sort might get the job
done
but I'm not sure.
--
Gregg


"JLGWhiz" wrote:

The following would change the 3rd and 4th characters of
a string to red font. If the characters are number data type,
this code fails.

Sub clrfnt()
Sheets(1).Range("A1").Characters(3, 2) _
.Font.ColorIndex = 3
End Sub


"Gregg" wrote:

I have values in cells A1:A10 expressed thusly: A1= 23_47
A2= 37_9
etc.. I would like to write code that will highlight individual
numbers in the cells A1:A10 that are greater than 32 and
less than 101. In cell A1 "47" would be highlighted, in cell
A2 "37" would be highlighted. Red can be the highlight color.
Gregg


JLGWhiz

Highlighting part of a cell contents in Excel 2003
 
Sorry, I took another look at your first posting and you are correct that the
characters function cannot be applied because you are trying to isolate part
of a string and evaluate it against a numerical value. That can be pretty
complex. Beyond my expertise.

"Gregg" wrote:

Thanks JLG, but I'm not sure how I could use your information in the example
I gave. I think a conditional for each loop of some sort might get the job
done
but I'm not sure.
--
Gregg


"JLGWhiz" wrote:

The following would change the 3rd and 4th characters of
a string to red font. If the characters are number data type,
this code fails.

Sub clrfnt()
Sheets(1).Range("A1").Characters(3, 2) _
.Font.ColorIndex = 3
End Sub


"Gregg" wrote:

I have values in cells A1:A10 expressed thusly: A1= 23_47
A2= 37_9
etc.. I would like to write code that will highlight individual
numbers in the cells A1:A10 that are greater than 32 and
less than 101. In cell A1 "47" would be highlighted, in cell
A2 "37" would be highlighted. Red can be the highlight color.
Gregg



All times are GMT +1. The time now is 05:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com