copy specific cells from sheet of one workbook into another sheet of other work book at specific location

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.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Try
Code:
Dim srcWB As Workbook
Dim destWB As Workbook


' Capture current file as source workbook
Set srcWB = ActiveWorkbook




' Add new workbook
Workbooks.Open fileName:="C:\mrexcel\book1.xlsm" 'destinationworkbook.xlsm"


' Capture destination workbook
Set destWB = ActiveWorkbook


' Copy data range from source to destination
srcWB.Sheets("Project_Details").Range("A2").Copy Range("K7")
srcWB.Sheets("Project_Details").Range("G2").Copy Range("D4")
srcWB.Sheets("Project_Details").Range("H2").Copy Range("D5")
srcWB.Sheets("Project_Details").Range("E2").Copy Range("D6")
srcWB.Sheets("Project_Details").Range("L2").Copy Range("D7")
srcWB.Sheets("Project_Details").Range("R2").Copy Range("K5")
srcWB.Sheets("Project_Details").Range("D2").Copy Range("K6")
srcWB.Sheets("Project_Details").Range("B2").Copy Range("K8")
Application.CutCopyMode = False
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top