Solved

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

Posted on 2014-01-10
3
339 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 51

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

Technology Partners: 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

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

695 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