-
Word Wrap in Excel Macro
Have a large amount of data on which to do a find/replace
routine. Current macro works fine, unless cell contains
multiple entries using word wrap. How can I look for
these specific multiple entries and replace with a single
coded entry?
I'm trying to replace this:
Irritant (Eyes, skin, respiratory tract)
Coughing, Choking, Headaches, Dizziness, Drowsiness
with:
Irritant-eyes-inhale-contact
Here's a snippet of the code I'm using:
Selection.Replace What:="Irritant (Eyes, skin,
respiratory tract)" & Chr(10) & "Coughing, Choking,
Headaches, Dizziness, Drowsiness", Replacement:="Irritant-
eyes-inhale-contact", LookAt:=xlWhole,
SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, ReplaceFormat:=False
Selection.Replace What:="Irritant (respiratory system,
skin)" & Chr(10) & "Risk of serious damage to eyes",
Replacement:="Irritant-eyes-inhale-contact",
LookAt:=xlWhole, SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, ReplaceFormat:=False
The first Selection.Replace works and the second doesn't.
Any suggestions?
-
Slection needs to include the text that you want ot replace, but since you says that your macro is working otherwise, I will assume that that is not the problem.
Look at what is actually in the cell. Is there actually a line feed forcing the new line, or is the text just wrapping to make it look like two lines? Are there any spaces after "skin)" or "eyes" that you don't see? If you aren't sure what is in the cell, run a loop on each character in the cell text and debug print the ASC value then look for any unexpected characters. :)