+ Reply to Thread
Results 1 to 10 of 10

Loop Search Text and cut/paste

  1. #1
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Loop Search Text and cut/paste

    This works but I don't know how to stop the loop (quit when it can't find "AR:") Thank you for any assistance


    Please Login or Register  to view this content.
    Last edited by ker9; 06-16-2010 at 03:41 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Help with Loop Search Text and cut/paste

    Hi ker9... Welcome to the forum.

    Be sure to read through the Forum Rules so you can use and follow them effectively. For instance, you'll need to EDIT that post above and put code tags around that code you used. (Like shown here...)


    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Help with Loop Search Text and cut/paste

    Thank you - sorry about that. I believe I fixed the original message.
    Your response is not quite what I'm after but I appreciate the help very much.

    (FYI: "AR:" is only in column A)
    After I find "AR:", I need to go over 1 column and copy cells from 8 columns (B:I)
    Then go up one row and paste starting in column C (C:J)
    Then I can delete the row that contains AR

    If I find AR and I am in the AR cell, this takes care of the copy/paste/delete. But with your code I don't seem to be in the AR cell that was found. I hope this makes sense.
    Please Login or Register  to view this content.
    Last edited by ker9; 06-16-2010 at 12:51 PM.

  4. #4
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Help with Loop Search Text and cut/paste

    Thank you - sorry about that. I believe I fixed the original message.
    Your response is not quite what I'm after but I appreciate the help very much.

    (FYI: "AR:" is only in column A)
    After I find "AR:", I need to go over 1 column and cut cells from 8 columns (B:I)
    Then go up one row and paste starting in column C (C:J)
    Then I can delete the row that contains AR - or I supposed I could delete this after I do all the cutting and pasting

    If I find AR and I am in the AR cell, this takes care of the copy/paste. But with your code I don't seem to be in the AR cell that was found. I hope this makes sense.
    Please Login or Register  to view this content.
    Last edited by ker9; 06-16-2010 at 12:51 PM.

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Help with Loop Search Text and cut/paste

    1) Please edit your prior posts and use CODE tags, not quote tags. Just edit them and change the word QUOTE to CODE in the tags. Thanks.

    2) I was really just trying to answer your specific question "how to loop for AR and stop when it's not found anymore". I assumed you would edit the code for the activities since I didn't exactly understand that part in your code.

    Now that you've explained it this one line of added code will do the copy/paste:
    Please Login or Register  to view this content.

    3) You'll note the absence of selecting and activecell and such. Only humans need to select a cell before acting on it. In VBA, you can refer to cells and ranges directly and act on them directly without selecting at all.

    I'm using a range variable to spot the "AR:" cells, so when it's found the address of the cell is stored in that variable and we can offset from there without selecting.

    In general, you want to remove as many physical references as you can.

  6. #6
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Thumbs up Re: Help with Loop Search Text and cut/paste

    OK, I've edited them again. For the record, the instructions say use the # button at the top of the post, which I never found until I realized I needed to click "Go Advanced" to see more options.

    THANK YOU! That is exactly what I wanted to do. I really appreciate your help and the time you took to work with me on this. I'm learning (slowly, but ...) (I've been searching the web for 3 hours trying to find a solution and trying different things before asking the question)

    Thank you Thank you Thank you

    Karin

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Help with Loop Search Text and cut/paste

    My pleasure, glad to help. The 3 hours is well spent if you end up with:

    1) The correct solution to the problem at hand
    2) A new resource for getting more correct solutions in the future


    ===========

    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  8. #8
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Loop Search Text and cut/paste

    Hi, Again - can you tell me how to get it to look only in column B (for find) (but not be restricted to B for copy/paste) ?
    Thank you.

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Loop Search Text and cut/paste

    You can control what gets searched in the RANGE reference underlined here:
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Loop Search Text and cut/paste

    It doesn't work when I do that (and yes I made sure I had the correct column to find it) It only works when it starts with "cells" as in the original.
    EXCEPT - if I change: After:=[A1] to After:=[B1]
    Then it works

    Thank you again - You're wonderful!!!
    Last edited by ker9; 06-16-2010 at 03:18 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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