SamarthSalunkhe
Board Regular
- Joined
- Jun 14, 2021
- Messages
- 103
- Office Version
- 2016
- Platform
- Windows
Hi All,
I am using below code to find unwanted character in cell, code is working fine but in addition I want code to highlight wrong value cell in red.
Thank you in Advance
I am using below code to find unwanted character in cell, code is working fine but in addition I want code to highlight wrong value cell in red.
VBA Code:
Sub Validate_File()
'Variable Declaration
Dim iCnt As Integer
Dim IpData As Range, DataRange As Range
Dim lr As Long
'-----------------------------------------------------------------------------------------------------------------------------------
'Below code will find Unwanted Characters in Account Number Column
lr = Sheet1.Range("F" & Rows.Count).End(xlUp).Row
'Create Object for Selected Range
Set DataRange = Sheets("Tally Format").Range("F2:F" & lr)
'Runnning for loop to check all available cells
For Each IpData In DataRange
For iCnt = 1 To Len(IpData.Value)
If Not Mid(IpData.Value, iCnt, 1) Like "[0-9A-Z]" Then
MsgBox "Unwanted Character fould in Column", vbExclamation, "Wrong A/c No"
Exit Sub
End If
Next iCnt
Next IpData
End Sub
Thank you in Advance