Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Unicode StrConv/Substitute routine...

It could have something to do with pasting this into an email, but the
character you show is char 191, which doesn't require unicode.

Not sure what you mean by Language equivalent.

Regards,
Tom Ogilvy



"Kevin Lyons" wrote in message
...
Hello,

I am trying to code a macro that will replace or substitute all "¿"

unicode
characters to their language equivalent using Application.Substitute

and/or
StrConv. I have written the below macro, but I am having trouble getting
it to do as I expect.

My thinking is to use the StrConv within the Application.Substitute

code...

The counter code that is commented works but for only a specific cell.
What I would like is the entire workbook changed accordingly. Can someone
assist?

--------------------------

Sub fixUnicode()

' counter = Range("A1046").Value
' strTest = StrConv(counter, vbFromUnicode)
' MsgBox "strTest = " & strTest
' Range("B1046").Value = strTest

For Each unicodeChar In ActiveSheet.UsedRange.Columns("A:AK").Cells
Range(unicodeChar.Address) =
Application.Substitute(unicodeChar.Value, "¿", StrConv("¿",

vbFromUnicode))
unicodeChar.WrapText = True
'okfilename =
Application.WorksheetFunction.Substitute(variousar tistsfilename, "-OK",

"")

'newfilename = StrConv(okfilename, vbProperCase)
Next

' For Each periodSlash In
ActiveSheet.UsedRange.Columns("AG:AK").Cells
' Range(periodSlash.Address) =
Application.Substitute(periodSlash.Value, _
' "./", "." & Chr(10))
' periodSlash.WrapText = True
' Next
' Selection.Replace What:="¿", Replacement:="?", LookAt:= _
' xlPart, SearchOrder:=xlByRows, MatchCase:=False

End Sub

--------------------------

Thanks,

Kevin



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Unicode StrConv/Substitute routine...

Tom,

I mean an upside down ? is what is showing in my Excel file. When I run the top
portion of the code on it, I get the associated Chinese or Japanese characters.

Assuming that it is unicode, do you have a solution?

Kevin


Tom Ogilvy wrote:

It could have something to do with pasting this into an email, but the
character you show is char 191, which doesn't require unicode.

Not sure what you mean by Language equivalent.

Regards,
Tom Ogilvy

"Kevin Lyons" wrote in message
...
Hello,

I am trying to code a macro that will replace or substitute all "¿"

unicode
characters to their language equivalent using Application.Substitute

and/or
StrConv. I have written the below macro, but I am having trouble getting
it to do as I expect.

My thinking is to use the StrConv within the Application.Substitute

code...

The counter code that is commented works but for only a specific cell.
What I would like is the entire workbook changed accordingly. Can someone
assist?

--------------------------

Sub fixUnicode()

' counter = Range("A1046").Value
' strTest = StrConv(counter, vbFromUnicode)
' MsgBox "strTest = " & strTest
' Range("B1046").Value = strTest

For Each unicodeChar In ActiveSheet.UsedRange.Columns("A:AK").Cells
Range(unicodeChar.Address) =
Application.Substitute(unicodeChar.Value, "¿", StrConv("¿",

vbFromUnicode))
unicodeChar.WrapText = True
'okfilename =
Application.WorksheetFunction.Substitute(variousar tistsfilename, "-OK",

"")

'newfilename = StrConv(okfilename, vbProperCase)
Next

' For Each periodSlash In
ActiveSheet.UsedRange.Columns("AG:AK").Cells
' Range(periodSlash.Address) =
Application.Substitute(periodSlash.Value, _
' "./", "." & Chr(10))
' periodSlash.WrapText = True
' Next
' Selection.Replace What:="¿", Replacement:="?", LookAt:= _
' xlPart, SearchOrder:=xlByRows, MatchCase:=False

End Sub

--------------------------

Thanks,

Kevin


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Unicode StrConv/Substitute routine...

Tom,

When I use my code:

Sub tester1()
counter = Range("A1").Value
strTest = StrConv(counter, vbFromUnicode)
MsgBox "strTest = " & strTest
Range("B1").Value = strTest

End Sub

This sub does provide for me the associated Chinese, Japanese, Taiwanese, etc.
characters returned into column B. The only thing is that this data resides
everywhere within the worksheet.

Do you know how to code the above subroutine into a For Next loop which checks
every cell in the spreadsheet rather than having to rely upon a single cell like
Range("A1").Value? It should also ignore those cells that do not have unicode
within them.

I hope this clarifies things some.

Thanks much,

Kevin


Tom Ogilvy wrote:

What are you trying to show. Perhaps all you need to do is apply a unicode
font to the cell. As I said, a "¿" is char 191 in Arial, so it isn't
unicode.

for me, running this with "¿" in Cell A1 diplays the same thing and puts
another "¿" in B1

Sub tester1()
counter = Range("A1").Value
strTest = StrConv(counter, vbFromUnicode)
MsgBox "strTest = " & strTest
Range("B1").Value = strTest

End Sub

Regards,
Tom Ogilvy

"Kevin Lyons" wrote in message
...
Tom,

I mean an upside down ? is what is showing in my Excel file. When I run

the top
portion of the code on it, I get the associated Chinese or Japanese

characters.

Assuming that it is unicode, do you have a solution?

Kevin


Tom Ogilvy wrote:

It could have something to do with pasting this into an email, but the
character you show is char 191, which doesn't require unicode.

Not sure what you mean by Language equivalent.

Regards,
Tom Ogilvy

"Kevin Lyons" wrote in message
...
Hello,

I am trying to code a macro that will replace or substitute all "¿"
unicode
characters to their language equivalent using Application.Substitute
and/or
StrConv. I have written the below macro, but I am having trouble

getting
it to do as I expect.

My thinking is to use the StrConv within the Application.Substitute
code...

The counter code that is commented works but for only a specific cell.
What I would like is the entire workbook changed accordingly. Can

someone
assist?

--------------------------

Sub fixUnicode()

' counter = Range("A1046").Value
' strTest = StrConv(counter, vbFromUnicode)
' MsgBox "strTest = " & strTest
' Range("B1046").Value = strTest

For Each unicodeChar In

ActiveSheet.UsedRange.Columns("A:AK").Cells
Range(unicodeChar.Address) =
Application.Substitute(unicodeChar.Value, "¿", StrConv("¿",
vbFromUnicode))
unicodeChar.WrapText = True
'okfilename =
Application.WorksheetFunction.Substitute(variousar tistsfilename,

"-OK",
"")

'newfilename = StrConv(okfilename, vbProperCase)
Next

' For Each periodSlash In
ActiveSheet.UsedRange.Columns("AG:AK").Cells
' Range(periodSlash.Address) =
Application.Substitute(periodSlash.Value, _
' "./", "." & Chr(10))
' periodSlash.WrapText = True
' Next
' Selection.Replace What:="¿", Replacement:="?", LookAt:= _
' xlPart, SearchOrder:=xlByRows, MatchCase:=False

End Sub

--------------------------

Thanks,

Kevin



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Unicode StrConv/Substitute routine...


Sub tester1()
Dim rng as Range, cell as Range
On error resume next
set rng = Activesheet.Cells.SpecialCells(xlConstants,xlTextV alues)
On error go to 0
if not rng is nothing then
for each cell in rng
counter = cell.Value
strTest = StrConv(counter, vbFromUnicode)
' MsgBox "strTest = " & strTest
cell.offset(0,1).Value = strTest
Next
End if
End Sub

--
Regards,
Tom Ogilvy


Kevin Lyons wrote in message
...
Tom,

When I use my code:

Sub tester1()
counter = Range("A1").Value
strTest = StrConv(counter, vbFromUnicode)
MsgBox "strTest = " & strTest
Range("B1").Value = strTest

End Sub

This sub does provide for me the associated Chinese, Japanese, Taiwanese,

etc.
characters returned into column B. The only thing is that this data

resides
everywhere within the worksheet.

Do you know how to code the above subroutine into a For Next loop which

checks
every cell in the spreadsheet rather than having to rely upon a single

cell like
Range("A1").Value? It should also ignore those cells that do not have

unicode
within them.

I hope this clarifies things some.

Thanks much,

Kevin


Tom Ogilvy wrote:

What are you trying to show. Perhaps all you need to do is apply a

unicode
font to the cell. As I said, a "¿" is char 191 in Arial, so it isn't
unicode.

for me, running this with "¿" in Cell A1 diplays the same thing and

puts
another "¿" in B1

Sub tester1()
counter = Range("A1").Value
strTest = StrConv(counter, vbFromUnicode)
MsgBox "strTest = " & strTest
Range("B1").Value = strTest

End Sub

Regards,
Tom Ogilvy

"Kevin Lyons" wrote in message
...
Tom,

I mean an upside down ? is what is showing in my Excel file. When I

run
the top
portion of the code on it, I get the associated Chinese or Japanese

characters.

Assuming that it is unicode, do you have a solution?

Kevin


Tom Ogilvy wrote:

It could have something to do with pasting this into an email, but

the
character you show is char 191, which doesn't require unicode.

Not sure what you mean by Language equivalent.

Regards,
Tom Ogilvy

"Kevin Lyons" wrote in message
...
Hello,

I am trying to code a macro that will replace or substitute all

"¿"
unicode
characters to their language equivalent using

Application.Substitute
and/or
StrConv. I have written the below macro, but I am having trouble

getting
it to do as I expect.

My thinking is to use the StrConv within the

Application.Substitute
code...

The counter code that is commented works but for only a specific

cell.
What I would like is the entire workbook changed accordingly. Can

someone
assist?

--------------------------

Sub fixUnicode()

' counter = Range("A1046").Value
' strTest = StrConv(counter, vbFromUnicode)
' MsgBox "strTest = " & strTest
' Range("B1046").Value = strTest

For Each unicodeChar In

ActiveSheet.UsedRange.Columns("A:AK").Cells
Range(unicodeChar.Address) =
Application.Substitute(unicodeChar.Value, "¿", StrConv("¿",
vbFromUnicode))
unicodeChar.WrapText = True
'okfilename =
Application.WorksheetFunction.Substitute(variousar tistsfilename,

"-OK",
"")

'newfilename = StrConv(okfilename, vbProperCase)
Next

' For Each periodSlash In
ActiveSheet.UsedRange.Columns("AG:AK").Cells
' Range(periodSlash.Address) =
Application.Substitute(periodSlash.Value, _
' "./", "." & Chr(10))
' periodSlash.WrapText = True
' Next
' Selection.Replace What:="¿", Replacement:="?", LookAt:= _
' xlPart, SearchOrder:=xlByRows, MatchCase:=False

End Sub

--------------------------

Thanks,

Kevin





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Unicode StrConv/Substitute routine...

Tom,

That appeared to do the trick; however, for those cells that didn't contain
unicode/multi-byte, it changed their values to unicode.

Thoughts?

Thanks much,

Kevin


Tom Ogilvy wrote:

Sub tester1()
Dim rng as Range, cell as Range
On error resume next
set rng = Activesheet.Cells.SpecialCells(xlConstants,xlTextV alues)
On error go to 0
if not rng is nothing then
for each cell in rng
counter = cell.Value
strTest = StrConv(counter, vbFromUnicode)
' MsgBox "strTest = " & strTest
cell.offset(0,1).Value = strTest
Next
End if
End Sub

--
Regards,
Tom Ogilvy

Kevin Lyons wrote in message
...
Tom,

When I use my code:

Sub tester1()
counter = Range("A1").Value
strTest = StrConv(counter, vbFromUnicode)
MsgBox "strTest = " & strTest
Range("B1").Value = strTest

End Sub

This sub does provide for me the associated Chinese, Japanese, Taiwanese,

etc.
characters returned into column B. The only thing is that this data

resides
everywhere within the worksheet.

Do you know how to code the above subroutine into a For Next loop which

checks
every cell in the spreadsheet rather than having to rely upon a single

cell like
Range("A1").Value? It should also ignore those cells that do not have

unicode
within them.

I hope this clarifies things some.

Thanks much,

Kevin


Tom Ogilvy wrote:

What are you trying to show. Perhaps all you need to do is apply a

unicode
font to the cell. As I said, a "¿" is char 191 in Arial, so it isn't
unicode.

for me, running this with "¿" in Cell A1 diplays the same thing and

puts
another "¿" in B1

Sub tester1()
counter = Range("A1").Value
strTest = StrConv(counter, vbFromUnicode)
MsgBox "strTest = " & strTest
Range("B1").Value = strTest

End Sub

Regards,
Tom Ogilvy

"Kevin Lyons" wrote in message
...
Tom,

I mean an upside down ? is what is showing in my Excel file. When I

run
the top
portion of the code on it, I get the associated Chinese or Japanese
characters.

Assuming that it is unicode, do you have a solution?

Kevin


Tom Ogilvy wrote:

It could have something to do with pasting this into an email, but

the
character you show is char 191, which doesn't require unicode.

Not sure what you mean by Language equivalent.

Regards,
Tom Ogilvy

"Kevin Lyons" wrote in message
...
Hello,

I am trying to code a macro that will replace or substitute all

"¿"
unicode
characters to their language equivalent using

Application.Substitute
and/or
StrConv. I have written the below macro, but I am having trouble
getting
it to do as I expect.

My thinking is to use the StrConv within the

Application.Substitute
code...

The counter code that is commented works but for only a specific

cell.
What I would like is the entire workbook changed accordingly. Can
someone
assist?

--------------------------

Sub fixUnicode()

' counter = Range("A1046").Value
' strTest = StrConv(counter, vbFromUnicode)
' MsgBox "strTest = " & strTest
' Range("B1046").Value = strTest

For Each unicodeChar In
ActiveSheet.UsedRange.Columns("A:AK").Cells
Range(unicodeChar.Address) =
Application.Substitute(unicodeChar.Value, "¿", StrConv("¿",
vbFromUnicode))
unicodeChar.WrapText = True
'okfilename =
Application.WorksheetFunction.Substitute(variousar tistsfilename,
"-OK",
"")

'newfilename = StrConv(okfilename, vbProperCase)
Next

' For Each periodSlash In
ActiveSheet.UsedRange.Columns("AG:AK").Cells
' Range(periodSlash.Address) =
Application.Substitute(periodSlash.Value, _
' "./", "." & Chr(10))
' periodSlash.WrapText = True
' Next
' Selection.Replace What:="¿", Replacement:="?", LookAt:= _
' xlPart, SearchOrder:=xlByRows, MatchCase:=False

End Sub

--------------------------

Thanks,

Kevin






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Unicode StrConv/Substitute routine...

Is there only one character in each cell:

Sub tester1()
Dim rng as Range, cell as Range
On error resume next
set rng = Activesheet.Cells.SpecialCells(xlConstants,xlTextV alues)
On error go to 0
if not rng is nothing then
for each cell in rng
counter = cell.Value
if ascw(counter) 256 then
strTest = StrConv(counter, vbFromUnicode)
' MsgBox "strTest = " & strTest
cell.offset(0,1).Value = strTest
End if
Next
End if
End Sub

---

Other wise, I think you would have to loop?
Sub tester1()
Dim rng as Range, cell as Range
Dim bUni as Boolean
On error resume next
set rng = Activesheet.Cells.SpecialCells(xlConstants,xlTextV alues)
On error go to 0
if not rng is nothing then
for each cell in rng
counter = cell.Value
if len(counter) < lenB(counter) then
strTest = StrConv(counter, vbFromUnicode)
' MsgBox "strTest = " & strTest
cell.offset(0,1).Value = strTest
End if
Next
End if
End Sub

If that doesn't work, I guess we would have to convert to a byte array and
check the hi bytes.

--
Regards,
Tom Ogilvy


Kevin Lyons wrote in message
...
Tom,

That appeared to do the trick; however, for those cells that didn't

contain
unicode/multi-byte, it changed their values to unicode.

Thoughts?

Thanks much,

Kevin


Tom Ogilvy wrote:

Sub tester1()
Dim rng as Range, cell as Range
On error resume next
set rng = Activesheet.Cells.SpecialCells(xlConstants,xlTextV alues)
On error go to 0
if not rng is nothing then
for each cell in rng
counter = cell.Value
strTest = StrConv(counter, vbFromUnicode)
' MsgBox "strTest = " & strTest
cell.offset(0,1).Value = strTest
Next
End if
End Sub

--
Regards,
Tom Ogilvy

Kevin Lyons wrote in message
...
Tom,

When I use my code:

Sub tester1()
counter = Range("A1").Value
strTest = StrConv(counter, vbFromUnicode)
MsgBox "strTest = " & strTest
Range("B1").Value = strTest

End Sub

This sub does provide for me the associated Chinese, Japanese,

Taiwanese,
etc.
characters returned into column B. The only thing is that this data

resides
everywhere within the worksheet.

Do you know how to code the above subroutine into a For Next loop

which
checks
every cell in the spreadsheet rather than having to rely upon a single

cell like
Range("A1").Value? It should also ignore those cells that do not have

unicode
within them.

I hope this clarifies things some.

Thanks much,

Kevin


Tom Ogilvy wrote:

What are you trying to show. Perhaps all you need to do is apply a

unicode
font to the cell. As I said, a "¿" is char 191 in Arial, so it

isn't
unicode.

for me, running this with "¿" in Cell A1 diplays the same thing

and
puts
another "¿" in B1

Sub tester1()
counter = Range("A1").Value
strTest = StrConv(counter, vbFromUnicode)
MsgBox "strTest = " & strTest
Range("B1").Value = strTest

End Sub

Regards,
Tom Ogilvy

"Kevin Lyons" wrote in message
...
Tom,

I mean an upside down ? is what is showing in my Excel file. When

I
run
the top
portion of the code on it, I get the associated Chinese or

Japanese
characters.

Assuming that it is unicode, do you have a solution?

Kevin


Tom Ogilvy wrote:

It could have something to do with pasting this into an email,

but
the
character you show is char 191, which doesn't require unicode.

Not sure what you mean by Language equivalent.

Regards,
Tom Ogilvy

"Kevin Lyons" wrote in message
...
Hello,

I am trying to code a macro that will replace or substitute

all
"¿"
unicode
characters to their language equivalent using

Application.Substitute
and/or
StrConv. I have written the below macro, but I am having

trouble
getting
it to do as I expect.

My thinking is to use the StrConv within the

Application.Substitute
code...

The counter code that is commented works but for only a

specific
cell.
What I would like is the entire workbook changed accordingly.

Can
someone
assist?

--------------------------

Sub fixUnicode()

' counter = Range("A1046").Value
' strTest = StrConv(counter, vbFromUnicode)
' MsgBox "strTest = " & strTest
' Range("B1046").Value = strTest

For Each unicodeChar In
ActiveSheet.UsedRange.Columns("A:AK").Cells
Range(unicodeChar.Address) =
Application.Substitute(unicodeChar.Value, "¿", StrConv("¿",
vbFromUnicode))
unicodeChar.WrapText = True
'okfilename =

Application.WorksheetFunction.Substitute(variousar tistsfilename,
"-OK",
"")

'newfilename = StrConv(okfilename, vbProperCase)
Next

' For Each periodSlash In
ActiveSheet.UsedRange.Columns("AG:AK").Cells
' Range(periodSlash.Address) =
Application.Substitute(periodSlash.Value, _
' "./", "." & Chr(10))
' periodSlash.WrapText = True
' Next
' Selection.Replace What:="¿", Replacement:="?", LookAt:=

_
' xlPart, SearchOrder:=xlByRows, MatchCase:=False

End Sub

--------------------------

Thanks,

Kevin






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
sub routine Gord Dibben Excel Discussion (Misc queries) 0 November 13th 09 12:15 AM
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE.... max. limit 8 :( [email protected] Excel Discussion (Misc queries) 6 May 22nd 08 05:33 PM
Sort Routine Platinum girl[_2_] Excel Discussion (Misc queries) 0 March 9th 07 03:21 PM
simplifying routine KneeDown2Up New Users to Excel 5 January 4th 07 05:28 PM
How to create a routine Tara Excel Discussion (Misc queries) 1 August 12th 05 02:28 AM


All times are GMT +1. The time now is 06:59 AM.

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

About Us

"It's about Microsoft Excel"