Hii im trying to copy and paste columns in sheet 1 to sheet 2 using the codes below:
'''Columns to copy from table1 in sheet1
Ary = Array("Name", "ID", "Language")
'''Define last of of table1 in sheet1
Dim LastRow As Long
Set Table1 = ThisWorkbook.Worksheets("Sheet1").ListObjects("Table1")
'''Copy and paste from sheet 1 to 2
Dim col As Long
col = 1
With Sheet1
For i = LBound(Ary) to UBound(Ary)
Set Fnd = Sheet1.ListObjects("Table1").HeaderRowRange.Find(Ary(i), , , xlWhole, , , False, , False)
If Not Fnd Is Nothing Then
col = col + 1
Table1.Cells(LastRow, Ary(i)).SpecialCells(xlCellTypeVisible).Copy Sheet2.Cells(1, col) ----> i keep getting error in this line
End If
Next i
End With
Any help will be greatly appreciated!
'''Columns to copy from table1 in sheet1
Ary = Array("Name", "ID", "Language")
'''Define last of of table1 in sheet1
Dim LastRow As Long
Set Table1 = ThisWorkbook.Worksheets("Sheet1").ListObjects("Table1")
'''Copy and paste from sheet 1 to 2
Dim col As Long
col = 1
With Sheet1
For i = LBound(Ary) to UBound(Ary)
Set Fnd = Sheet1.ListObjects("Table1").HeaderRowRange.Find(Ary(i), , , xlWhole, , , False, , False)
If Not Fnd Is Nothing Then
col = col + 1
Table1.Cells(LastRow, Ary(i)).SpecialCells(xlCellTypeVisible).Copy Sheet2.Cells(1, col) ----> i keep getting error in this line
End If
Next i
End With
Any help will be greatly appreciated!