I am trying to copy the sheet1 range data to sheet2 range but nothing gets copied. This is the full code which I was trying to achieve something but got stuck in the basic place. Please help
Edit: I tried the Macro just now and the same thing happened with this code. Please see the snapshot where you can see that Snap 1 contains source data and also selected but does not get copied to Snap 2. However the ranges are selected there.
Sub copy()
Range("A1:J4").Select
Selection.copy
Sheets("Sheet2").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.Save
End Sub


UpDate
Style-1
Option Explicit
Dim objSheet1,objSheet2,TotalRows,TotalcolCopy,strPathExcel1
Dim oXls : Set oXls = CreateObject("Excel.Application")
Dim aData ': aData = oWb.Worksheets(1).Range("$A2:$C10")
Dim dicP : Set dicP = CreateObject("Scripting.Dictionary")
strPathExcel1 = "D:\WIPData\AravoMacro\Finalscripts\GE_Wing_To_Wing_Report.xlsx"
oXls.Workbooks.open strPathExcel1
Set objSheet1 = oXls.ActiveWorkbook.Worksheets(1)
Set objSheet2 = oXls.ActiveWorkbook.Worksheets(2)
TotalRows=oXls.Application.WorksheetFunction.CountA(objSheet1.Columns(1)) - 3
TotalcolCopy=oXls.Application.WorksheetFunction.Match("Parent Business Process ID", objSheet1.Rows(3), 0)
objSheet1.Range(objSheet1.Cells(4,1),objSheet1.Cells(TotalRows,TotalcolCopy)).Copy(objSheet2.Range("A1"))
'=======================
oXls.ActiveWorkbook.SaveAs strPathExcel1
oXls.Workbooks.close
oXls.Application.Quit
'======================
Style-2
Option Explicit
Dim objSheet1,objSheet2,TotalRows,TotalcolCopy,strPathExcel1
Dim oFS : Set oFS = CreateObject("Scripting.FileSystemObject")
Dim oXls : Set oXls = CreateObject("Excel.Application")
Dim aData ': aData = oWb.Worksheets(1).Range("$A2:$C10")
Dim dicP : Set dicP = CreateObject("Scripting.Dictionary")
oXls.Workbooks.Open(oFs.GetAbsolutePathName("Test.xlsx"))
Set objSheet1 = oXls.ActiveWorkbook.Worksheets(1)
Set objSheet2 = oXls.ActiveWorkbook.Worksheets(2)
TotalRows=oXls.Application.WorksheetFunction.CountA(objSheet1.Columns(1)) - 3
TotalcolCopy=oXls.Application.WorksheetFunction.Match("Parent Business Process ID", objSheet1.Rows(3), 0)
objSheet1.Range(objSheet1.Cells(4,1),objSheet1.Cells(TotalRows,TotalcolCopy)).Copy(objSheet2.Range("A1"))
'=======================
oXls.ActiveWorkbook.SaveAs "Test.xlsx"
oXls.Workbooks.close
oXls.Application.Quit
'======================
Could you people tell me what differences between Style-1 and Style-2.Because in Style-1 all the copied data get saved,which is not the case in Style-2. This design issue mainly the overall problem i was facing from morning.
In what way Style-2 is not perfect?
The simplest way to copy from one range to another would be to recoding macro. Looking at your code, what are the values you are getting for
TotalRowsandLastCol? Assuming you have matching data returned from yourMatch(), so there’re rows to copy`So in your case, can you keep it simple? Remove the following line. Just specify the starting Range of the Sheet2 and try out. You do not have to worry about
resizeat this point.replace this,
with either: coz you are missing paste special argument
or : here without any fancy cells, but direct range