what I want is to copy data from book1 sheet2 this part and paste to to book2 sheet2 and save book2 excel file and close book2 excel file

what I want is to copy data from book1 sheet2  this part and paste to  to book2 sheet2 and save book2 excel file and close book2 excel file
I have highlighted this in yellow colour, this is just for understanding, in this yellow part I have data no yellow colour
I want to do this only by vba
kindly see book2 sheet2  
kindly see book1 sheet2
Book1.xlsm
Book2.xlsm
Avinash SinghAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Please give this a try...

Place the following code on a Standard Module of Book1.xlsm.
Sub CopyDataFromBook1ToBook2()
Dim swb As Workbook, dwb As Workbook
Dim sws As Worksheet, dws As Worksheet
Dim RngToCopy As Range, destRng As Range
Dim FilePath As String, FileName As String

Application.ScreenUpdating = False

'Set the source workbook
Set swb = ThisWorkbook

'Set the source worksheet
Set sws = swb.Sheets("Sheet2")

'Set the range to be copied
Set RngToCopy = sws.Range("B2:W25")

'Assuming the destination and the source workbooks are saved in the same folder
FilePath = swb.Path & "\"

'Name of the destination workbook
FileName = "Book2.xlsm"

'Get the destination workbook if already opened
On Error Resume Next
Set dwb = Workbooks("Book2.xlsm")
On Error GoTo 0

'If destination workbook is not opened, open it
If dwb Is Nothing Then
    Set dwb = Workbooks.Open(FilePath & FileName)
End If

'Set the destination worksheet
Set dws = dwb.Sheets("Sheet2")

'Set destination range
Set destRng = dws.Range("B2")

'Copy the source range and paste it
RngToCopy.Copy destRng

'Save destination workbook with all the changes made
dwb.Close True

Application.ScreenUpdating = True
End Sub

Open in new window

Book1.xlsm

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Avinash SinghAuthor Commented:
Thnx again Neeraj sir for giving ur precious time to my post
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You're welcome Avinash!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.