View Full Version : Solved: search text in a worksheet then copy the whole column to master sheet
farrukh
02-16-2012, 10:05 PM
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
harish1805
02-16-2012, 11:14 PM
you can either use vlookup or a sql statement on the main file in VBA.
farrukh
02-18-2012, 05:58 AM
Will you please provide some example please?
cheers
mdmackillop
02-18-2012, 09:02 AM
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
farrukh
02-19-2012, 12:07 AM
Hi mdmackillop,
Perfect this is what i need too...
Thank you have a great time...
Cheers
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.