Colour 0 separated by vertical bar in any position

Kishan

Well-known Member
Joined
Mar 15, 2011
Messages
1,648
Office Version
  1. 2010
Platform
  1. Windows
Using Excel 2000
Hi,

I need VBA to get coloured 0 as shown in the example below

[TABLE="width: 207"]
<colgroup><col></colgroup><tbody>[TR]
[TD]0 | 0 | 0 | 1 | 1 | 1 | 1[/TD]
[/TR]
[TR]
[TD]0 | 0 | 1 | 1 | 1 | 0 | 1[/TD]
[/TR]
[TR]
[TD]0 | 0 | 1 | 1 | 1 | 1 | 0[/TD]
[/TR]
[TR]
[TD]0 | 0 | 1 | 0 | 1 | 1 | 0[/TD]
[/TR]
[TR]
[TD]0 | 0 | 1 | 1 | 1 | 1 | 0[/TD]
[/TR]
[TR]
[TD]0 | 0 | 1 | 1 | 1 | 0 | 1[/TD]
[/TR]
[TR]
[TD]0 | 0 | 1 | 1 | 1 | 1 | 0[/TD]
[/TR]
[TR]
[TD]0 | 1 | 0 | 1 | 1 | 0 | 1[/TD]
[/TR]
[TR]
[TD]0 | 1 | 0 | 1 | 1 | 1 | 0[/TD]
[/TR]
[TR]
[TD]0 | 1 | 1 | 0 | 0 | 0 | 0[/TD]
[/TR]
[TR]
[TD]0 | 1 | 1 | 0 | 1 | 0 | 0[/TD]
[/TR]
[TR]
[TD]0 | 1 | 1 | 0 | 1 | 1 | 1[/TD]
[/TR]
[TR]
[TD]0 | 1 | 1 | 1 | 0 | 1 | 1[/TD]
[/TR]
</tbody>[/TABLE]


Thank you in advance

Regards,
Kishan
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
How about
Code:
Sub Kishan()
   Dim Cl As Range
   Dim i As Long
   
   For Each Cl In Range("A1", Range("A" & Rows.Count).End(xlUp))
      For i = 1 To Len(Cl) Step 2
         If Mid(Cl, i, 1) = "0" Then Cl.Characters(i, 1).Font.Color = vbRed
      Next i
   Next Cl
End Sub
 
Upvote 0
How about
Code:
Sub Kishan()
   Dim Cl As Range
   Dim i As Long
   
   For Each Cl In Range("A1", Range("A" & Rows.Count).End(xlUp))
      For i = 1 To Len(Cl) Step 2
         If Mid(Cl, i, 1) = "0" Then Cl.Characters(i, 1).Font.Color = vbRed
      Next i
   Next Cl
End Sub
Fluff, the code worked as required!

Thank you for your help

Kind Regards,
Kishan
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,703
Messages
6,173,973
Members
452,540
Latest member
haasro02

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