[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2014-01-10
3
Medium Priority
?
346 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
3 Comments
 
LVL 54

Accepted Solution

by:
Rgonzo1971 earned 1000 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 28

Assisted Solution

by:MacroShadow
MacroShadow earned 1000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

872 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