Closed Thread
Results 1 to 3 of 3

Copy rows if specific text in coloum A

  1. #1
    Registered User
    Join Date
    01-08-2014
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    23

    Post Copy rows if specific text in coloum A

    I found this macro in google.. please edit this for my needs,,

    I have some specific procucts in coloum A in sheet (data), If that product was found in Sheets("allproducts"), copy all the rows and create a new sheet on the product name and save the excel.


    Please help me in this..



    Sub SearchForString()

    Dim LSearchRow As Integer
    Dim LCopyToRow As Integer

    On Error GoTo Err_Execute

    'Start search in row 1
    LSearchRow = 1

    'Start copying data to row 2 in Sheet2 (row counter variable)
    LCopyToRow = 2

    While Len(Range("H" & CStr(LSearchRow)).Value) > 0

    'If value in column H = "product1", copy entire row to Sheet2
    If Range("H" & CStr(LSearchRow)).Value = "product1" Then

    'Select row in allproducts to copy
    Rows(CStr(LSearchRow) & ":" & CStr(LSearchRow)).Select
    Selection.Copy

    'Paste row into Sheet2 in next row
    Sheets("Sheet2").Select
    Rows(CStr(LCopyToRow) & ":" & CStr(LCopyToRow)).Select
    ActiveSheet.Paste

    'Move counter to next row
    LCopyToRow = LCopyToRow + 1

    'Go back to allproducts to continue searching
    Sheets("allproducts").Select

    End If

    LSearchRow = LSearchRow + 1

    Wend

    'Position on cell A2
    Application.CutCopyMode = False
    Range("A2").Select






    MsgBox "All matching data has been copied."

    Exit Sub

    Err_Execute:
    MsgBox "An error occurred."

    End Sub

  2. #2
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Copy rows if specific text in coloum A

    Welcome to the forum.

    We'd like to help you but first..

    Pls take some minutes to read forum rules and specially-in this case- rule#3
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  3. #3
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Copy rows if specific text in coloum A

    Thread closed AS DUPLICATE.

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Copy rows from worksheets that contain specific text into a summary worksheet.
    By ChocksterNo1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-04-2013, 11:04 AM
  2. marcro to delete rows if coloum is over value
    By Kezwick in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-14-2011, 03:11 AM
  3. text to coloum
    By arnab0711 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-28-2008, 04:26 PM
  4. text to coloum
    By bahadirakcan in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-19-2006, 02:34 AM
  5. [SOLVED] Copy/Paste Rows that Contain Specific Text
    By Mike Woodard in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-08-2006, 03:40 PM

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