+ Reply to Thread
Results 1 to 5 of 5

select row where value in column matches text field

  1. #1
    Forum Contributor
    Join Date
    07-22-2009
    Location
    Minneapolis, MN
    MS-Off Ver
    2016
    Posts
    220

    select row where value in column matches text field

    Hi all,
    I have a table that's say, 1000 rows, and occasionally one row of the table needs to be copied and pasted so that their are two entries.

    I intend to have a cell where the user can enter a number, and the macro would copy the row of the table that has the matching number in Column A.


    Let's say the user entered the number "387" in to the cell, then clicked the button to run the macro.

    The macro would look in range A4:A1003 for the value "387", select that row, copy, and insert it one row down.


    Any ideas?

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: select row where value in column matches text field

    Please Login or Register  to view this content.
    If you are happy with my response please click the * in the lower left of my post.

  3. #3
    Forum Contributor
    Join Date
    07-22-2009
    Location
    Minneapolis, MN
    MS-Off Ver
    2016
    Posts
    220

    Re: select row where value in column matches text field

    Thanks Stnky!

    That's a really good start for what I'm needing to accomplish...

    Couple of questions:

    How can I change "r.Insert", so that the copied line is inserted below "r.EntireRow" instead of above?
    After the copied row is inserted, I need to clear any contents that are in columns Q:U for that inserted row.
    Lastly, Column A is a formula to generate the numbers... Cell A5 formula is: =A4+1... After inserting the copied row, I will need to select the cell in column A, and copy the formula down one row to update the formula that was copied/inserted.

    I think that is everything that needs to happen, can you please help me expand it al little bit?

  4. #4
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: select row where value in column matches text field

    How can I change "r.Insert", so that the copied line is inserted below "r.EntireRow" instead of above?
    r.Offset(1).Insert

    After the copied row is inserted, I need to clear any contents that are in columns Q:U for that inserted row.
    Range("Q" & r.Row + 1, "U" & r.Row + 1).ClearContents

    Lastly, Column A is a formula to generate the numbers... Cell A5 formula is: =A4+1... After inserting the copied row, I will need to select the cell in column A, and copy the formula down one row to update the formula that was copied/inserted.
    r.Resize(2, 1).FillDown

  5. #5
    Forum Contributor
    Join Date
    07-22-2009
    Location
    Minneapolis, MN
    MS-Off Ver
    2016
    Posts
    220

    Re: select row where value in column matches text field

    Quote Originally Posted by stnkynts View Post
    r.Offset(1).Insert



    Range("Q" & r.Row + 1, "U" & r.Row + 1).ClearContents



    r.Resize(2, 1).FillDown
    Thanks!!!!

    Though "r.Resize(2, 1).FillDown" didn't work quite right, but thanks to the code you provided, I came up with:

    Please Login or Register  to view this content.
    and that did the trick!

    Thank you so much for your help!

+ 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. [SOLVED] How to search each consecutive column if a certain field matches?
    By hockeyadc in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 06-07-2013, 02:53 PM
  2. [SOLVED] IF name in column A matches then copy data in other field
    By Blue Fishey in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-16-2012, 04:38 PM
  3. Replies: 5
    Last Post: 03-06-2008, 01:27 PM
  4. Can't select field in ADO with Text Driver
    By Greg Lovern in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-29-2006, 08:00 PM
  5. [SOLVED] how do I count the number of times text in column A matches text i
    By Sheila in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-16-2005, 06:25 PM
  6. Select text from a field
    By Bob in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-02-2005, 06:40 PM
  7. [SOLVED] Select text from a field
    By Bob in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-02-2005, 06:17 PM

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