+ Reply to Thread
Results 1 to 4 of 4

Find text and cut/paste that row.

  1. #1
    Registered User
    Join Date
    12-10-2013
    Location
    West Yorkshire, UK
    MS-Off Ver
    Excel 2007
    Posts
    6

    Find text and cut/paste that row.

    Hello.

    I wondered if anyone could help, I'm having trouble figuring out how I could get this to work.
    I have a little experience with Macro's and a tiny, tiny amount of experience with VB, so please go easy on me.

    I've got an excel database to track my stock. I'm wanting a macro/VB to be able to help find a particular row easily.

    The details of my stock is stored on a sheet called "Stock List".

    On a sheet called "Modify Stock" I want to be able to type an item's barcode into cell D8. I then want to press the Macro button, and I need the macro to search column B on "Stock List" for an exact match.

    When a match is found I then need the Macro to cut the data from that entire row from "Stock List" to row 30 of "Modify Stock" (from column B onwards)

    Does that make any sense? Is it possible?

    Thank you very much for any help.

    Tom.

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

    Re: Find text and cut/paste that row.

    This part got confusing
    When a match is found I then need the Macro to cut the data from that entire row from "Stock List" to row 30 of "Modify Stock" (from column B onwards)
    How about this:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    12-10-2013
    Location
    West Yorkshire, UK
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Find text and cut/paste that row.

    Sorry about the confusion, but I think you got the idea, because the code you've written works well, thank you!

    The only tweak I need is for the Macro to either Cut the data from the worksheet rahter than Copy it, or (even better) to delete the empty row - if you have any suggestions I would be really greatful.

    Thanks again for the brilliant help.
    Last edited by BreatGritain; 12-10-2013 at 06:23 PM.

  4. #4
    Registered User
    Join Date
    12-10-2013
    Location
    West Yorkshire, UK
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Find text and cut/paste that row.

    I have worked it out using your code,

    Sub BreatGritain()
    Dim ws1 As Worksheet: Set ws1 = Sheets("Modify Stock")
    Dim ws2 As Worksheet: Set ws2 = Sheets("Stock List")
    Dim rFind As Range

    Set rFind = ws2.Range("B1:B" & ws2.Range("B" & Rows.Count).End(xlUp).Row).Find(What:=ws1.Range("D8").Value, LookIn:=xlValues, LOokat:=xlWhole)
    If Not rFind Is Nothing Then
    rFind.EntireRow.Copy Destination:=ws1.Range("A30")
    rFind.EntireRow.Delete

    Else
    MsgBox ("Could not find the stock")
    End If

    End Sub
    Thank you so, 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. find text and cut/paste cell below
    By treur in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-16-2012, 07:46 AM
  2. [SOLVED] Find text - copy and paste to different sheet
    By Tortus in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-20-2012, 12:31 PM
  3. Find and paste from text file
    By guerillaexcel in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-15-2011, 04:40 AM
  4. Find and paste from text file
    By guerillaexcel in forum Access Programming / VBA / Macros
    Replies: 4
    Last Post: 02-15-2011, 04:37 AM
  5. Find text then paste to different sheet
    By jpthelpguy in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-20-2009, 02:52 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