+ Reply to Thread
Results 1 to 5 of 5

trying to find string in row 1 of sheet but for some reason it does not work.

  1. #1
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    trying to find string in row 1 of sheet but for some reason it does not work.

    See enclosed file.

    I dont understand why my code does not work. In this example i am trying to find the contents of cell A1. But for some reason the formatting of this cell prevents me from finding a match the text string.....any ideas how to get around this because in my main program i need to be able to find these header strings.
    Attached Files Attached Files
    Last edited by welchs101; 11-14-2011 at 01:06 PM.

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: trying to find string in row 1 of sheet but for some reason it does not work.

    Hi

    You have a line feed (ascii 10) in the string so it doesn't match the string you have put into the variable string_to_find.

    If you make it
    Please Login or Register  to view this content.
    then it will bring back 1 as I think you expect.

    rylo
    Last edited by rylo; 11-10-2011 at 11:32 PM.

  3. #3
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: trying to find string in row 1 of sheet but for some reason it does not work.

    thanks. that worked just as i hoped it would.

    But how did you know what character value to use? How did you know there was even a character you needed to insert?

    thanks

  4. #4
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: trying to find string in row 1 of sheet but for some reason it does not work.

    adding the Chr(10) does solve the problem.

    however, when i try to add the following line of code i get a compile error ......any ideas why?

    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: trying to find string in row 1 of sheet but for some reason it does not work.

    Hi

    1) Know character was there - experience, and as the text is line wrapped, then a line feed was the first choice.

    2) If you don't know what the ascii code is, then try the formula
    Please Login or Register  to view this content.
    . This will bring back the 10.

    3) compile error. From the help file on const
    You can't use variables, user-defined functions, or intrinsic Visual Basic functions (such as Chr) in expressions assigned to constants.
    rylo

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1