Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Check that only ASCII chars are used

Hi,
What would be the possibilities to check that only ASCII chars are used
within one file?

Thanks in advance once again
Markku
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Check that only ASCII chars are used

what sort of file, xls, txt....

Regards,
Peter T

"Makelei" wrote in message
...
Hi,
What would be the possibilities to check that only ASCII chars are used
within one file?

Thanks in advance once again
Markku



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Check that only ASCII chars are used

Hi,
xls and 2003

BR
MakeLei

"Peter T" wrote:

what sort of file, xls, txt....

Regards,
Peter T

"Makelei" wrote in message
...
Hi,
What would be the possibilities to check that only ASCII chars are used
within one file?

Thanks in advance once again
Markku




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Check that only ASCII chars are used

So are you saying you want to check if any text cells contain characters in
the range chr(x) where x is between 128 and 255

Also, could any formula cells return text with these characters.

For the result do you just want a yes/no answer or any information about
which cells contain non ASCII characte5rs

Regards,
Peter T



"Makelei" wrote in message
...
Hi,
xls and 2003

BR
MakeLei

"Peter T" wrote:

what sort of file, xls, txt....

Regards,
Peter T

"Makelei" wrote in message
...
Hi,
What would be the possibilities to check that only ASCII chars are used
within one file?

Thanks in advance once again
Markku






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Check that only ASCII chars are used

Hi,
I just want to high light the cell with pink. I have about 30 000 rows and
30 columns in use.

This is to be used as data is entered to cell. Sub Worksheet_Change(ByVal
Target As Range)

BR
MakeLei

"Peter T" wrote:

So are you saying you want to check if any text cells contain characters in
the range chr(x) where x is between 128 and 255

Also, could any formula cells return text with these characters.

For the result do you just want a yes/no answer or any information about
which cells contain non ASCII characte5rs

Regards,
Peter T



"Makelei" wrote in message
...
Hi,
xls and 2003

BR
MakeLei

"Peter T" wrote:

what sort of file, xls, txt....

Regards,
Peter T

"Makelei" wrote in message
...
Hi,
What would be the possibilities to check that only ASCII chars are used
within one file?

Thanks in advance once again
Markku








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Check that only ASCII chars are used

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count = 1 Then
CheckASCII Target
End If
End Sub
Sub CheckASCII(Target As Range)
Dim text As String
Dim ascii As Long
Dim pos As Long
text = Target.text
For pos = 1 To Len(text)
Select Case Asc(Mid(text, pos, 1))
Case 27 To 255 'CHECK THESE!
Case Else
Target.Interior.ColorIndex = vbRed
Exit Sub
End Select
Next
End Sub

"Makelei" wrote in message
...
Hi,
I just want to high light the cell with pink. I have about 30 000 rows and
30 columns in use.

This is to be used as data is entered to cell. Sub Worksheet_Change(ByVal
Target As Range)

BR
MakeLei

"Peter T" wrote:

So are you saying you want to check if any text cells contain characters
in
the range chr(x) where x is between 128 and 255

Also, could any formula cells return text with these characters.

For the result do you just want a yes/no answer or any information about
which cells contain non ASCII characte5rs

Regards,
Peter T



"Makelei" wrote in message
...
Hi,
xls and 2003

BR
MakeLei

"Peter T" wrote:

what sort of file, xls, txt....

Regards,
Peter T

"Makelei" wrote in message
...
Hi,
What would be the possibilities to check that only ASCII chars are
used
within one file?

Thanks in advance once again
Markku






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Check that only ASCII chars are used

What you now say you want is very different to what you asked in your OP

this is only lightly tested -

Private Sub Worksheet_Change(ByVal Target As Range)
Dim bIsASCII As Boolean
Dim nClr1 As Long, nClr2 As Long
Dim ba() As Byte
Dim cel As Range

For Each cel In Target
ba = CStr(cel.Value)

If IsNumeric(cel) Then
bIsASCII = True
Else
bIsASCII = IsAllASCII(ba)
End If

With cel.Interior
nClr1 = .ColorIndex
nClr2 = 0
If bIsASCII Then
If nClr1 = 38 Then nClr2 = xlNone
Else
If nClr1 < 38 Then nClr2 = 38
End If
If nClr2 Then .ColorIndex = nClr2

End With
Next
End Sub

Function IsAllASCII(ba() As Byte) As Boolean
Dim bFlag As Boolean
Dim i As Long

For i = 0 To UBound(ba) - 1 Step 2
If ba(i) < 128 And ba(i + 1) = 0 Then
' it's an ASCII
Else
bFlag = True
Exit For
End If
Next
IsAllASCII = Not bFlag

End Function

Regards,
Peter T

"Makelei" wrote in message
...
Hi,
I just want to high light the cell with pink. I have about 30 000 rows and
30 columns in use.

This is to be used as data is entered to cell. Sub Worksheet_Change(ByVal
Target As Range)

BR
MakeLei

"Peter T" wrote:

So are you saying you want to check if any text cells contain characters
in
the range chr(x) where x is between 128 and 255

Also, could any formula cells return text with these characters.

For the result do you just want a yes/no answer or any information about
which cells contain non ASCII characte5rs

Regards,
Peter T



"Makelei" wrote in message
...
Hi,
xls and 2003

BR
MakeLei

"Peter T" wrote:

what sort of file, xls, txt....

Regards,
Peter T

"Makelei" wrote in message
...
Hi,
What would be the possibilities to check that only ASCII chars are
used
within one file?

Thanks in advance once again
Markku








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
How to truncate list of meaningful words greater than 15 chars tomeaningful words of 8 chars. Babloo Excel Worksheet Functions 4 April 29th 11 11:27 PM
sum first 2 chars if 3rd is something... [email protected] Excel Discussion (Misc queries) 13 September 29th 06 02:30 PM
determine if ea value in a col has more than 20 chars pmms Excel Discussion (Misc queries) 2 March 16th 06 03:11 PM
Removing last three chars teresa Excel Programming 3 January 24th 05 12:29 AM
URGENT! check if cell has only ALPHA chars No Name Excel Programming 5 September 29th 04 09:27 PM


All times are GMT +1. The time now is 07:00 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"