Consulting

Results 1 to 5 of 5

Thread: Solved: search text in a worksheet then copy the whole column to master sheet

  1. #1
    VBAX Regular
    Joined
    Jan 2011
    Posts
    62
    Location

    Solved: search text in a worksheet then copy the whole column to master sheet

    Hi All,

    I need a piece of code that search a specific string in a worksheet if find then copy the column to master sheet on specific column. i need it for multiples strings how it can be?


    Thanks
    farrukh

  2. #2
    you can either use vlookup or a sql statement on the main file in VBA.

  3. #3
    VBAX Regular
    Joined
    Jan 2011
    Posts
    62
    Location
    Will you please provide some example please?

    cheers

  4. #4
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [vba]Sub CopyCol()
    Dim arr(), a
    Dim ws As Worksheet
    Dim i As Long
    Dim c as Range

    Set ws = Sheets(2)
    arr = Array("aaa", 2, "bbb", 5, "ccc", 7, "ddd", 12)
    For i = 0 To UBound(arr) - 1 Step 2
    Set c = ActiveSheet.Cells.Find(arr(i))
    If Not c Is Nothing Then c.EntireColumn.Copy ws.Cells(1, arr(i + 1))
    Next
    End Sub[/vba]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    VBAX Regular
    Joined
    Jan 2011
    Posts
    62
    Location
    Hi mdmackillop,

    Perfect this is what i need too...

    Thank you have a great time...


    Cheers

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •