D
Dudely
I pull a string off a webpage. The string looks something like this "I
%20am%20a%20string".
I want to stuff it into an Excel cell, but without the %20. As we all
know, %20 is the representation for the space character. I looked
everywhere I could think of to find a function that would convert to a
plain text string, but couldn't find anything supplied by Excel. So,
I decided to build my own.
I walk through the string and copy character by character, until I
find a percent character, skip over the 3 chars making up the %20 and
repeat until done. Seems to work fine, until I try to copy it into
the cell. At that point what I have are a bunch of unprintiable
characters. That's when I realized I had forgotten to use the CHR
function. However, when I tried to use the CHR function, it gives me
a type mismatch. So, at this point I admit I don't know what I'm
doing and I need some help.
The calls to Strconv are essentially useless, but again I admit I
don't know what I'm doing. I use it as a quick way to fill "x".
Thank you in advance
Dim i As Long
Dim x() As Byte
x = StrConv(Subject, vbFromUnicode) ' Convert string.
ReDim tmpSubject(UBound(x))
For i = 0 To UBound(x) ' get rid of %20 string
If x(i) = 37 Then ' 37 is the percent sign
i = i + 2 ' "Next" command will add 1 more
Debug.Print " "
tmpSubject(i) = ChrB(20)
Else
Debug.Print ChrB(x(i))
tmpSubject(i) = ChrB(x(i)) <==== type mismatch
End If
Next
Subject = StrConv(tmpSubject, vbUnicode) ' A failed experiment.
%20am%20a%20string".
I want to stuff it into an Excel cell, but without the %20. As we all
know, %20 is the representation for the space character. I looked
everywhere I could think of to find a function that would convert to a
plain text string, but couldn't find anything supplied by Excel. So,
I decided to build my own.
I walk through the string and copy character by character, until I
find a percent character, skip over the 3 chars making up the %20 and
repeat until done. Seems to work fine, until I try to copy it into
the cell. At that point what I have are a bunch of unprintiable
characters. That's when I realized I had forgotten to use the CHR
function. However, when I tried to use the CHR function, it gives me
a type mismatch. So, at this point I admit I don't know what I'm
doing and I need some help.
The calls to Strconv are essentially useless, but again I admit I
don't know what I'm doing. I use it as a quick way to fill "x".
Thank you in advance
Dim i As Long
Dim x() As Byte
x = StrConv(Subject, vbFromUnicode) ' Convert string.
ReDim tmpSubject(UBound(x))
For i = 0 To UBound(x) ' get rid of %20 string
If x(i) = 37 Then ' 37 is the percent sign
i = i + 2 ' "Next" command will add 1 more
Debug.Print " "
tmpSubject(i) = ChrB(20)
Else
Debug.Print ChrB(x(i))
tmpSubject(i) = ChrB(x(i)) <==== type mismatch
End If
Next
Subject = StrConv(tmpSubject, vbUnicode) ' A failed experiment.