ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Count funtion (https://www.excelbanter.com/excel-programming/410769-count-funtion.html)

Yossy

Count funtion
 
Please I have a column of middle names. Most middle names are 1 character and
some are more than 1 character. Is there a formula that can help me know if
some middle names are more than 1 character and possible highlight or color.

All help totally appreciated.

JW[_2_]

Count funtion
 
On May 11, 11:08*pm, Yossy wrote:
Please I have a column of middle names. Most middle names are 1 character and
some are more than 1 character. Is there a formula that can help me know if
some middle names are more than 1 character and possible highlight or color.


Gary Keramidas

Count funtion
 
if they're all in a separate column, maybe this will help. i used sheet1 and
column B in my example.

Sub test()
Dim ws As Worksheet
Dim lastrow As Long
Dim rng As Range
Dim cell As Range
Dim cntr As Long
Set ws = Worksheets("Sheet1")
lastrow = ws.Cells(Rows.Count, "B").End(xlUp).Row
Set rng = ws.Range("b2:B" & lastrow)

For Each cell In rng
If Len(cell) 1 Then
cell.Interior.ColorIndex = 19
cntr = cntr + 1
Else
cell.Interior.ColorIndex = 0
End If
Next
MsgBox cntr & " names with more than 1 character."
End Sub


--


Gary


"Yossy" wrote in message
...
Please I have a column of middle names. Most middle names are 1 character and
some are more than 1 character. Is there a formula that can help me know if
some middle names are more than 1 character and possible highlight or color.

All help totally appreciated.





All times are GMT +1. The time now is 01:51 AM.

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