Solved

macro to copy data from work book a and paste to workbook b

Posted on 2014-01-10
3
333 Views
Last Modified: 2014-01-10
Hi Expert's excel 2007

I need a macro to copy data from work book a which will be open when running the macro...to copy and paste special all into work book b at file path :"\\hfhjyukkgt\gjutjkk\workbook b.xlsx

data range a1:gg15000 workbook a

and paste the data into sheet Master cell a1...then close work book b down..

then the next time work book a is open delete the existing data and replace with the new data from wrk a when macro is re run
0
Comment
Question by:route217
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 50

Accepted Solution

by:
Rgonzo1971 earned 250 total points
ID: 39770805
Hi,

pls try

Sub Macro()
Set SrcWbk = ActiveWorkbook
Set SrcSht = SrcWbk.ActiveSheet
Set DestWbk = Workbooks.Open("YourFile")
DestWbk.Worksheets("Master").Cells.Delete
SrcSht.Range("A1:GG15000").Copy
DestWbk.Worksheets("Master").Range("A1").PasteSpecial xlPasteAll
DestWbk.Close xlSaveChanges
End Sub

Open in new window

Regards
0
 
LVL 27

Assisted Solution

by:MacroShadow
MacroShadow earned 250 total points
ID: 39770860
Alternatively, try this:

Sub Demo()

    Dim wbDestination As Workbook
    Dim rngSource As Range
    Dim rngDestination As Range

    Set wbDestination = Workbooks.Open("\\hfhjyukkgt\gjutjkk\workbook b.xlsx")
    Set rngSource = ActiveSheet.Range("A1:GG15000")
    Set rngDestination = wbDestination.Sheets("Master").Range("A1:GG15000")

    rngDestination.Clear

    rngDestination.Value = rngSource.Value

    wbDestination.Close

End Sub

Open in new window

0
 

Author Closing Comment

by:route217
ID: 39771294
Excellent feedback
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question