+ Reply to Thread
Results 1 to 10 of 10

Find text between two rows dynamically

  1. #1
    Registered User
    Join Date
    12-06-2012
    Location
    Oxford, England
    MS-Off Ver
    Excel 2010
    Posts
    11

    Find text between two rows dynamically

    I want to find a text between two rows. Here are some code snippets:

    Please Login or Register  to view this content.
    but it gives me a mismatch type error and I don't know how to fix it.

    I tried to convert it to string but still didn't help me.

    Thank you in advance!

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Find text between two rows dynamically

    What line gives the error? Are rowI & rowF dim'ed as type Long ? Is Search dim'ed as type Range?

    Can you show the code previous to this?

  3. #3
    Registered User
    Join Date
    12-06-2012
    Location
    Oxford, England
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Find text between two rows dynamically

    The set Search line gives error.
    Yes they are all dim'ed.

    Here's the code
    Please Login or Register  to view this content.
    I tried to use the address instead of row but didn't help me or maybe I didn't know how to write it properly.
    Last edited by JoTedy; 12-07-2012 at 06:38 PM.

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Find text between two rows dynamically

    If one of the previous searches for rowI or rowF fail, then the search for the "in between" will error because one of those variables is not defined.

    Try putting each subsequent search within the previous search's If-End If code block. Or test the two variable values before searching in between.

  5. #5
    Registered User
    Join Date
    12-06-2012
    Location
    Oxford, England
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Find text between two rows dynamically

    How do I test the two variables? I used MsgBox to see if both of variables have values and they do.

    The problem I think is in this line of code

    Please Login or Register  to view this content.
    or maybe I didn't make them the right type of data

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Find text between two rows dynamically

    Data type Long should be correct for both rowI and rowF.

    This range reference should be correct Range("B" & rowI & ":B" & rowF) as long as the values for rowI & rowF are greater than zero and rowI is less than rowF

    To test the values...
    IF rowI > 0 and rowI < rowF then

    Otherwise, can you attach your workbook?

  7. #7
    Registered User
    Join Date
    12-06-2012
    Location
    Oxford, England
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Find text between two rows dynamically

    I've attached it ( I hope )

  8. #8
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Find text between two rows dynamically

    Try this...

    Please Login or Register  to view this content.
    The "After" range should be within the search range.

  9. #9
    Registered User
    Join Date
    12-06-2012
    Location
    Oxford, England
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Find text between two rows dynamically

    thank you AlphaFrog

  10. #10
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Find text between two rows dynamically

    You're welcome.

    You could also omit the After argument.

+ 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