Formula not copying last row to new sheet

Posted on 2014-03-17
Last Modified: 2014-03-18
I did not create this code.  It is copying data from IO Staging to Inbound, but counting rows on Variances Tab.  It was not copying the last row of the IO Staging tab and thus not copying it to the Inbound tab.  

I changed this row to say +3 instead of +2 and it seems to work
    lRow = Sheets("Variances").Range("A" & Rows.Count).End(xlUp).Row + 3

Can someone tell me if that was what I needed to do and if so why.


    lRow = Sheets("Variances").Range("A" & Rows.Count).End(xlUp).Row + 3
    zrow = Sheets("Variances").Range("A" & Rows.Count).End(xlUp).Row
    Sheets("Inbound").Range("A6:A" & lRow).Value = "A"
    Sheets("Inbound").Range("C6:C" & lRow).Value = Sheets("IO Staging").Range("C3:C" & zrow).Value
Question by:leezac
  • 3
  • 2
LVL 39

Accepted Solution

nutsch earned 500 total points
ID: 39935164
It's strange that you're getting your row numbers from the Variances sheet rather than the IO Staging sheet you are copying from:  

lRow = Sheets("IO Staging").Range("A" & Rows.Count).End(xlUp).Row + 3
zrow = Sheets("IO Staging").Range("C" & Rows.Count).End(xlUp).Row
Sheets("Inbound").Range("A6:A" & lRow).Value = "A"
Sheets("Inbound").Range("C6:C" & lRow).Value = Sheets("IO Staging").Range("C3:C" & zrow).Value

Author Comment

ID: 39935171
I agree

Author Comment

ID: 39936872
What did changing this number accomphish?

Row + 3
LVL 39

Assisted Solution

nutsch earned 500 total points
ID: 39936928
You're copying a range that goes from c3 to zrow into a range that starts at c6. The +3 extends the destination range and makes  it fit. Without it, you're copying n rows into n-3 rows.

Author Closing Comment

ID: 39936987
Great response and help.

Featured Post

Industry Leaders: 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

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
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 will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

680 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