Solved

copying data from current workbook to another different ranges

Posted on 2011-03-23
5
269 Views
Last Modified: 2012-05-11
excel 2003
need a vba sub
to be placed behind a command button


2 workbooks
1.  workingcopy.xls
1st workbook can be placed and used from anywhere
sheet name =  sheet1


2.
C:\PROGRAM FILES\DATA1\FINAL.XLS
always in this location
sheet name =  sheet1

Column Headers in BOTH worksheets
A1:AU1

The data will always start on row2 in  workingcopy.xls

THE amount of rows will always vary...

copying data from  workingcopy.xls  to final.xls




Thanks
fordraiders





0
Comment
Question by:fordraiders
[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
  • 2
  • 2
5 Comments
 
LVL 7

Accepted Solution

by:
Jignesh Thar earned 500 total points
ID: 35204649
Use below in workingcopy

Sub CopyData()
    Range("A2:AU65536").Copy
    Workbooks.Open Filename:= _
        "D:\Documents and Settings\jignesh.thar\My Documents\FINAL.xls"
    Range("A2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
    ActiveWorkbook.Save
    ActiveWindow.Close
    Range("A1").Select
End Sub

Open in new window

0
 
LVL 7

Expert Comment

by:Jignesh Thar
ID: 35204651
Replace path "D:\Documents and Settings\jignesh.thar\My Documents\FINAL.xls" with C:\PROGRAM FILES\DATA1\FINAL.XLS
0
 
LVL 6

Expert Comment

by:TinTombStone
ID: 35205273
Assuming that the headers in both Working and Final are the same

Run this from workingcopy.xls

Sub CopyToFinal()

Dim rng As Range

    Set rng = Range("'[C:\PROGRAM FILES\DATA1\FINAL.XLS]Sheet1'!A1")

    Range("A1").CurrentRegion.Copy rng

End Sub
0
 
LVL 6

Expert Comment

by:TinTombStone
ID: 35205288
Sorry, scrub the above.  I'm just not thinking straight, jigneshthar has it right
0
 
LVL 3

Author Closing Comment

by:fordraiders
ID: 35208237
Thanks
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

749 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