Results 1 to 2 of 2

Thread: Word Wrap in Excel Macro

  1. #1

    Thread Starter
    Fanatic Member doofusboy's Avatar
    Join Date
    Apr 2003
    Posts
    526

    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?
    Do canibals not eat clowns because they taste funny?

  2. #2
    Fanatic Member WorkHorse's Avatar
    Join Date
    Jul 2002
    Location
    Where you live.
    Posts
    591
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width