+ Reply to Thread
Results 1 to 7 of 7

Copy cells between two found instances of a different strings

  1. #1
    Registered User
    Join Date
    04-02-2013
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    28

    Copy cells between two found instances of a different strings

    Hi everyone,

    I'm trying to write a code that searches for instances of a string within a cell within a range, and then copies everything between that cell and the next instance of a different string.

    Sounds confusing, but essentially I have multiple ranges between a cell containing 'Posts:' and a cell containing 'Logged', and these ranges differ in size, but are always contained between these two cells.

    This is what I have so far:

    Please Login or Register  to view this content.
    But I keep getting a 'Compile Error: invalid qualifier', likely because the 'rng1.Row' output is not being treated as an integer.

    Is there a way around this?

    Thanks so much in advance for all your help.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,937

    Re: Copy cells between two found instances of a different strings

    When you run the code and get the error, what line of code is highlighted when you click on debug?
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Copy cells between two found instances of a different strings

    Did not really look into whether your code tackles your problem, but to fix that problem, you can try just removing the Set.

    Please Login or Register  to view this content.
    You only use Set for object variables, such as Range, Worksheet, etc.
    多么想要告诉你 我好喜欢你

  4. #4
    Registered User
    Join Date
    04-02-2013
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    28

    Re: Copy cells between two found instances of a different strings

    Hi alansidman,

    the line I get the error with is the

    Please Login or Register  to view this content.
    the first line of the loop. Which leads me to think that it doesn't like the rng2.Row variables.

  5. #5
    Registered User
    Join Date
    04-02-2013
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    28

    Re: Copy cells between two found instances of a different strings

    yep, that was exactly the problem haha

    thanks so much for your help millz!!

  6. #6
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Copy cells between two found instances of a different strings

    Set int1 = rng2.Row - rng1.Row

    try without SET
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  7. #7
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,937

    Re: Copy cells between two found instances of a different strings

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Copy if two cells found
    By frank35 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-19-2013, 02:35 PM
  2. [SOLVED] Find various strings and copy the found string in column A of the row it appears in.
    By equanet in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-29-2012, 02:55 PM
  3. Replies: 4
    Last Post: 02-16-2012, 11:29 AM
  4. Comparing strings and counting instances in a complex datasheet
    By rpthoth in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-21-2011, 03:54 PM
  5. Calculation of instances a value is found in a series of cells
    By DSBTX in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-24-2006, 03:10 AM

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