Solved

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

Posted on 2014-01-10
3
322 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 48

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 26

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
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 …
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now