Solved

VBA Copy Range

Posted on 2014-02-05
2
206 Views
Last Modified: 2014-02-05
Hi,
Could I please get assistance would like to update the range so that if the file is updated and goes paste 1321 the data is captured?

Here is my code so far:

Set wbPaste = ActiveWorkbook
    Set wbCopy = Workbooks.Open("\Phased.XLS")
    Set wsCopy = wbCopy.Worksheets("SS")
    Set rngCopy = wsCopy.Range("A5:HX1321")
     
    Set wsPaste = wbPaste.Worksheets("DataSheet")
    Set rngPaste = wsPaste.Range("a4")
    

Open in new window

0
Comment
Question by:jmac001
2 Comments
 
LVL 35

Accepted Solution

by:
mvidas earned 500 total points
ID: 39836986
Just change the "set rngcopy" line as follows, should do the trick:
'    Set rngCopy = wsCopy.Range("A5:HX1321")
    Set rngCopy = Intersect(wsCopy.Range("A5:HX" & wsCopy.Rows.Count), wsCopy.UsedRange.EntireRow)

Open in new window

Matt
0
 

Author Closing Comment

by:jmac001
ID: 39836999
Thank you Matt just what I was looking for.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
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 …
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

685 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