Hi Everyone,
I've searched Google, YouTube, and this site but didn't find what I needed. Any help is appreciated.
I have a macro on a workbook that runs on another open workbook; all code is based on the column name using a FindColumn sub.
This code needs to highlight cells in the column if they're blank, or not in ###-###-####, (###)###-####, or ########## format however it highlights cells in (###)###-#### format and I can't figure out why.
Anyone have any ideas or a better code I can use?
I've searched Google, YouTube, and this site but didn't find what I needed. Any help is appreciated.
I have a macro on a workbook that runs on another open workbook; all code is based on the column name using a FindColumn sub.
This code needs to highlight cells in the column if they're blank, or not in ###-###-####, (###)###-####, or ########## format however it highlights cells in (###)###-#### format and I can't figure out why.
Anyone have any ideas or a better code I can use?
VBA Code:
Sub PhoneNbr(ws As Worksheet, lastCol As Long, lastRow As Long)
Dim rng As Range, cell As Range
Dim word As Variant
Dim colLtr As String
colLtr = FindColumn(ws, "Phone Number", 2)
If colLtr = "Null" And lastRow > 2 Then
Else
Set rng = ws.Range(colLtr & "3:" & colLtr & CStr(lastRow))
rng.FormatConditions.Delete
For Each cell In rng
If cell Like "###-###-####" Or cell Like "##########" Or cell Like Trim("(###)###-####") Then
cell.Interior.Color = xlNone
Else
cell.Interior.Color = RGB(255, 204, 0)
With ws.Range(colLtr & "2")
.Interior.Color = RGB(0, 0, 0)
.Font.Color = RGB(255, 255, 255)
End With
End If
Next cell
End If
End Sub