Option Explicit
Sub CopyData()
Dim i As Integer, lastRow As Long
Dim PstRng As Range
lastRow = Range("A" & Rows.Count).End(xlUp).Row
Sheet2.[2:65536].EntireRow.Delete
For i = 1 To 256
Set PstRng = Sheet2.Range("1:1").Find(Cells(1, i).Value, [A1], xlValues, xlWhole)
If Not PstRng Is Nothing Then
Range(Cells(2, i), Cells(lastRow, i)).Copy PstRng.Offset(1, 0)
End If
Next i
End Sub
I have specified in my previous message "Its not work" really doesn't tell anything useful. What happens?Shrivallavha column its work but i put in rows till 10000 then its not work
Option Explicit
Sub CopyData()
Dim i As Integer, lastRow As Long
Dim PstRng As Range
lastRow = Cells.Find("*", [A1], xlFormulas, xlPart, xlByRows, xlPrevious, False).Row
Sheet2.[2:65536].EntireRow.Delete
For i = 1 To 256
Set PstRng = Sheet2.Range("1:1").Find(Cells(1, i).Value, [A1], xlValues, xlWhole)
If Not PstRng Is Nothing Then
Range(Cells(2, i), Cells(lastRow, i)).Copy PstRng.Offset(1, 0)
End If
Next i
End Sub
OK. Try this code.no give error but not pull last row data also then it is not work
Option Explicit
Sub CopyData()
Dim i As Integer, lastRow As Long
Dim PstRng As Range
lastRow = Cells.Find("*", [A1], xlFormulas, xlPart, xlByRows, xlPrevious, False).Row
Sheet2.[2:65536].EntireRow.Delete
For i = 1 To 256
Set PstRng = Sheet2.Range("1:1").Find(Cells(1, i).Value, [A1], xlValues, xlWhole)
If Not PstRng Is Nothing Then
Range(Cells(2, i), Cells(lastRow, i)).Copy PstRng.Offset(1, 0)
End If
Next i
End Sub