hi,
Try the below code.
Sub copycolumns()
'
' copycolumns Macro
' Variable Declaration
'
Dim strColName As String
Dim intRng As Integer
Dim i as Integer
Dim strVal As String
intRng = InputBox("Enter the No. of Columns?", "No. of columns") 'To get the No. of Columns Available to Search
strColName = InputBox("Enter the Column Name to Copy?", "Column Name") 'To Get the Column Name to Search
strSheetName = InputBox("Enter the Sheet Name to Paste?", "Sheet Name")'To get the Sheet Name to paste the content
For i = 1 To intRng
'Store the Cell Value
strVal = Cells(1, i)
'Check the Value with the User given column name
If UCase(strVal) = UCase(strColName) Then
'Select and Copy
Cells(1, i).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
'Select and Paste
Sheets(strSheetName).Select
Range("A1").Select
ActiveSheet.Paste
End If
Next
End Sub Shailaja:)I have a spreadsheet that has many columns. I want to search the titles of the columns and copy all the content in the column that satifies the search criterion and paste it in different worksheet. Copying these columns manually is very time consuming and I wanted to create Macro that automate searching (based on their column title), copying (all contents in the column) and pasting (to a separate worksheet).
Any help is appreciated.
Thanks,