Jagdev Singh
Active Member
Hi Experts
I want to copy the specific columns from one sheet to another sheet. The below code is working fine, but the count of columns is more than 20. Using this code will be hectic. Could you please help me with the way I can copy the selected columns from one sheet to another.
I want to copy the specific columns from one sheet to another sheet. The below code is working fine, but the count of columns is more than 20. Using this code will be hectic. Could you please help me with the way I can copy the selected columns from one sheet to another.
Code:
Sub CopyColumnByTitle()
'Find "Entity" in Row 1
With Sheets("RAW_Client").Rows(1)
Set t = .Find("Entity", lookat:=xlPart)
'If found, copy the column to Sheet 2, Column A
'If not found, present a message
If Not t Is Nothing Then
Columns(t.Column).EntireColumn.Copy _
Destination:=Sheets("Client").Range("A1")
Else: MsgBox "Name Not Found"
End If
End With
'Find "Department" in Row 1
With Sheets("RAW_Client").Rows(1)
Set t = .Find("Department", lookat:=xlPart)
'If found, copy the column to Sheet 2, Column A
'If not found, present a message
If Not t Is Nothing Then
Columns(t.Column).EntireColumn.Copy _
Destination:=Sheets("Client").Range("B1")
Else: MsgBox "Age Not Found"
End If
End With
End Sub