Hello Syed,
Here is your macro re-written using object variables. This makes the code easier to read and follow. When writing code for multiple Workbooks, it is easy to lose track of what is doing what.
Sub test3()
Dim LastColumn As Long
Dim LastRow As Long
Dim Rng1 As Range
Dim Rng2 As Range
Dim Wkb1 As Workbook
Dim Wkb2 As Workbook
Dim Wks1 As Worksheet
Dim Wks2 As Worksheet
Set Wkb1 = ThisWorkbook
Set Wkb2 = "DataAll.xls"
Set Wks1 = Wkb1.Worksheets(Wkb1.ActiveSheet.Name)
Set Wks2 = Wkb2.Worksheets("Sheet2")
Set Rng1 = Wkb1.Application.Selection
LastRow = Rng1.Rows.Count
LastColumn = Wks2.Cells(1, Wks2.Columns.Count).End(xlToLeft).Column
Set Rng2 = Wks2.Range(Cells(1, LastColumn), Cells(LastRow, LastColumn))
Rng1.Copy
Rng2.PasteSpecial (xlPasteAll)
Application.CutCopyMode = False
End Sub
Sincerely,
Leith Ross
Bookmarks