UzmaSKhan116
New Member
- Joined
- Oct 23, 2018
- Messages
- 7
Hi,
i want to copy specific cells from sheet 5 of workbook1 to sheet1 of workbook into specific cells only, without opening a destination workbook.
i am trying like this but i don't know, y its not working well for multiple values
Dim srcWB As Workbook
Dim destWB As Workbook
' Capture current file as source workbook
Set srcWB = ActiveWorkbook
' Add new workbook
Workbooks.Open Filename:="C:\destinationworkbook.xlsm"
' Capture destination workbook
Set destWB = ActiveWorkbook
' Copy data range from source to destination
srcWB.Sheets("Project_Details").Range("A2").Copy
srcWB.Sheets("Project_Details").Range("G2").Copy
srcWB.Sheets("Project_Details").Range("H2").Copy
srcWB.Sheets("Project_Details").Range("E2").Copy
srcWB.Sheets("Project_Details").Range("L2").Copy
srcWB.Sheets("Project_Details").Range("R2").Copy
srcWB.Sheets("Project_Details").Range("D2").Copy
srcWB.Sheets("Project_Details").Range("B2").Copy
destWB.Activate
Range("K7").Select
Range("D4").Select
Range("D5").Select
Range("D6").Select
Range("D7").Select
Range("K5").Select
Range("K6").Select
Range("K8").Select
ActiveSheet.Paste
Application.CutCopyMode = False
please help me out to fix the error. the above code works well for 2 values only.
i want to copy specific cells from sheet 5 of workbook1 to sheet1 of workbook into specific cells only, without opening a destination workbook.
i am trying like this but i don't know, y its not working well for multiple values
Dim srcWB As Workbook
Dim destWB As Workbook
' Capture current file as source workbook
Set srcWB = ActiveWorkbook
' Add new workbook
Workbooks.Open Filename:="C:\destinationworkbook.xlsm"
' Capture destination workbook
Set destWB = ActiveWorkbook
' Copy data range from source to destination
srcWB.Sheets("Project_Details").Range("A2").Copy
srcWB.Sheets("Project_Details").Range("G2").Copy
srcWB.Sheets("Project_Details").Range("H2").Copy
srcWB.Sheets("Project_Details").Range("E2").Copy
srcWB.Sheets("Project_Details").Range("L2").Copy
srcWB.Sheets("Project_Details").Range("R2").Copy
srcWB.Sheets("Project_Details").Range("D2").Copy
srcWB.Sheets("Project_Details").Range("B2").Copy
destWB.Activate
Range("K7").Select
Range("D4").Select
Range("D5").Select
Range("D6").Select
Range("D7").Select
Range("K5").Select
Range("K6").Select
Range("K8").Select
ActiveSheet.Paste
Application.CutCopyMode = False
please help me out to fix the error. the above code works well for 2 values only.