Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Identify non-alphanumeric characters within a cell in Excel

I need a macro in Excel that will:
(a) identify non-alphnumeric characters within a cell,
(b) within range A1:G60000
(c) and mark each cell with such a character in a way that I can easily
identify the cells with FIND or by sorting

I found this macro here but all it does is change the color of the
non-alphanumeric characters. I have 180,000 rows to look through so I
need a way to aggregate all of the exceptions in a short list so I can
deal with them.

Sub Test()
For Each cell In Range("A1:G50000").Cells
For i = 1 To Len(cell)
Select Case Asc(Mid(cell.Value, i, 1))
Case 48 To 57, 65 To 90, 79 To 122
cell.Characters(Start:=i, Length:=1).Font.ColorIndex =
1
Case Else
cell.Characters(Start:=i, Length:=1).Font.ColorIndex =
3
End Select
Next i
Next
End Sub

Thanks for your help!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,393
Default Identify non-alphanumeric characters within a cell in Excel

Any use:
Sub Test()
For Each cell In Range("A1:G50").Cells
For i = 1 To Len(cell)
Select Case Asc(Mid(cell.Value, i, 1))
Case 48 To 57, 65 To 90, 79 To 122
' cell.Characters(Start:=i, Length:=1).Font.ColorIndex = 1
Case Else
cell.Value = "test " & cell.Value
End Select
Next i
Next
End Sub

--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

wrote in message
oups.com...
I need a macro in Excel that will:
(a) identify non-alphnumeric characters within a cell,
(b) within range A1:G60000
(c) and mark each cell with such a character in a way that I can easily
identify the cells with FIND or by sorting

I found this macro here but all it does is change the color of the
non-alphanumeric characters. I have 180,000 rows to look through so I
need a way to aggregate all of the exceptions in a short list so I can
deal with them.

Sub Test()
For Each cell In Range("A1:G50000").Cells
For i = 1 To Len(cell)
Select Case Asc(Mid(cell.Value, i, 1))
Case 48 To 57, 65 To 90, 79 To 122
cell.Characters(Start:=i, Length:=1).Font.ColorIndex =
1
Case Else
cell.Characters(Start:=i, Length:=1).Font.ColorIndex =
3
End Select
Next i
Next
End Sub

Thanks for your help!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,393
Default Identify non-alphanumeric characters within a cell in Excel

Alternative:
Sub Test2()
For Each cell In Range("A1:G50").Cells
check = 0
For i = 1 To Len(cell)
Select Case Asc(Mid(cell.Value, i, 1))
Case 48 To 57, 65 To 90, 79 To 122
check = check
Case Else
check = check + 1
End Select
Next i
If check 0 Then cell.Value = "test " & cell.Value
Next
End Sub


--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"Bernard Liengme" wrote in message
...
Any use:
Sub Test()
For Each cell In Range("A1:G50").Cells
For i = 1 To Len(cell)
Select Case Asc(Mid(cell.Value, i, 1))
Case 48 To 57, 65 To 90, 79 To 122
' cell.Characters(Start:=i, Length:=1).Font.ColorIndex = 1
Case Else
cell.Value = "test " & cell.Value
End Select
Next i
Next
End Sub

--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

wrote in message
oups.com...
I need a macro in Excel that will:
(a) identify non-alphnumeric characters within a cell,
(b) within range A1:G60000
(c) and mark each cell with such a character in a way that I can easily
identify the cells with FIND or by sorting

I found this macro here but all it does is change the color of the
non-alphanumeric characters. I have 180,000 rows to look through so I
need a way to aggregate all of the exceptions in a short list so I can
deal with them.

Sub Test()
For Each cell In Range("A1:G50000").Cells
For i = 1 To Len(cell)
Select Case Asc(Mid(cell.Value, i, 1))
Case 48 To 57, 65 To 90, 79 To 122
cell.Characters(Start:=i, Length:=1).Font.ColorIndex =
1
Case Else
cell.Characters(Start:=i, Length:=1).Font.ColorIndex =
3
End Select
Next i
Next
End Sub

Thanks for your help!





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Identify non-alphanumeric characters within a cell in Excel

This worked well, thank you.

I didn't define my problem perfectly: I wanted it to ignore spaces,
dashes and apostrophes. So I just did FIND/REPLACE on those characters
and this worked perfectly. Thanks for saving me a ton of time.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
File names appended with ~ plus alphanumeric characters Augied Excel Discussion (Misc queries) 0 January 13th 09 04:23 AM
HOW DO YOU COUNT ALPHA CHARACTERS IN AN ALPHANUMERIC FIELD PVSPRO Excel Discussion (Misc queries) 4 August 31st 07 12:04 AM
format cell to place colon btw every 2 alphanumeric characters hogsy Excel Worksheet Functions 0 August 17th 06 03:30 PM
Search for non alphanumeric characters jmdaniel Excel Programming 14 February 21st 06 09:08 PM
Strip Alpha Characters out of an Alphanumeric Dataset supersonicf111 Excel Programming 22 January 2nd 04 11:57 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"