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
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
  • 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
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 will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

759 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