+ Reply to Thread
Results 1 to 4 of 4

Macro will not select new text to search for when run

  1. #1
    Registered User
    Join Date
    01-20-2012
    Location
    Boston
    MS-Off Ver
    Excel 2007
    Posts
    2

    Macro will not select new text to search for when run

    Hello,

    I hate to have my first post on a forum be crying for help, but to be honest I know NOTHING about macros so here goes.

    I want to copy a selected cell, search another page for that value/string, when found, copy the cell to its right, then paste that value/string to the right of the originally selected cell.

    The problem I am getting is the code is telling Excel to search for "text" which is fine, but when i run the macro from another cell, it keeps that "text" from the previous and searches for that. Here is my code:
    Please Login or Register  to view this content.
    The "What" is what needs to be changed somehow to whatever value is in the cell i select first then run the macro.

    Thanks!
    Last edited by -ftp-; 01-20-2012 at 12:25 PM.

  2. #2
    Forum Contributor
    Join Date
    06-16-2011
    Location
    London
    MS-Off Ver
    Excel XP
    Posts
    276

    Re: Macro will not select new text to search for when run

    Try using a string variable instead.

    Please Login or Register  to view this content.
    etc etc.

  3. #3
    Registered User
    Join Date
    01-20-2012
    Location
    Boston
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Macro will not select new text to search for when run

    Oh I love you kind sir, that did it!!

    here is another question:

    Can I make this repeat (loop) down an entire column? I have about 300 + of these to do and hate clicking a cell each time then running the macro.

    Thanks!
    Last edited by -ftp-; 01-20-2012 at 12:38 PM.

  4. #4
    Forum Contributor
    Join Date
    06-16-2011
    Location
    London
    MS-Off Ver
    Excel XP
    Posts
    276

    Re: Macro will not select new text to search for when run

    A very simple loop:

    Please Login or Register  to view this content.

    Or if you know exactly where the end of your data is you could use a proper loop (FOR NEXT, etc) which is much better programming practice than using GOTO commands but then I'm a lazy programmer.
    Last edited by swoop99; 01-20-2012 at 12:47 PM.

+ 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