1

I tried looking around for this particular problem, but couldn't find it.

I am trying to replace an assortment of characters in a string.

I tried looping through the characters using their character codes, but my code will ?randomly? delete the entire string instead of just the special characters. (basically I just want the letters and numbers from the string) EG. ABC-3.3%H14T-6 I would just want ABC33H14T6

What is strange about this (to me) is that my code will delete the string on a random character, it's not always chr(41) or whatever, it changes each time I run the code.. is it maybe a formatting issue?

For Char = 33 To 47
Sheets("Sheet1").Cells(FRow, 44).Replace What:=Chr(Char), Replacement:="", LookAt:=xlPart
Next Char

I would give you the bulk of my code, but it is work-sensitive.

Any advice would be appreciated!

Thanks guys.

1
  • 1
    Nevermind I just realized Chr(42) was the culprit. I dunno what I was smoking to think it was random. Chr(42) = * Commented Jan 10, 2014 at 22:01

1 Answer 1

5

I'm dumb Chr(42) = *

which would replace everything. durr

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.