Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# Formula not copying last row to new sheet

Posted on 2014-03-17
Medium Priority
265 Views
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.

---------------------------------------------------------------------------

Sheets("Inbound").Select

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
0
Question by:leezac
[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
• 3
• 2

LVL 39

Accepted Solution

nutsch earned 2000 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
0

Author Comment

ID: 39935171
I agree
0

Author Comment

ID: 39936872
What did changing this number accomphish?

Row + 3
0

LVL 39

Assisted Solution

nutsch earned 2000 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.
0

Author Closing Comment

ID: 39936987
Great response and help.
0

## Featured Post

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,…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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 demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
###### Suggested Courses
Course of the Month4 days, 9 hours left to enroll