This is just an example so you can repeat what I've done.
Sub test(src_Sheet As String, dst_Sheet As String)
Dim x As Long
Dim last_Row As Long
With Sheets(src_Sheet)
.Range(.Range("A" & 2), .Range("A" & 65536).End(xlUp)).Copy
End With
last_Row = Worksheets(dst_Sheet).Range("A65536").End(xlUp).Row
Sheets(dst_Sheet).Range("A" & last_Row + 1).PasteSpecial Paste:=xlValues
Worksheets(dst_Sheet).Activate
Worksheets(dst_Sheet).Range("A1").Select
Worksheets(src_Sheet).Activate
End Sub
It is simple code but hear is the hang up. I am copying formulas from the source sheet. So when I call this function a second time and use a different source sheet but the same source sheet...
excel thinks the last_Row is wherever my formula was even though I pasted the values only.
So I copy some formulas.
= B1 + C1 + D1
= B2 + C2 + D2
= B3 + C3 + D3
= D4 + C4 + D4
but only the first two have actual values in them.
A1 = 5
A2 = 6
A3 = nothing
A4 = nothing
so on the second call to the function excel thinks the last row is A4 even though it is actually A2.
So what is causing excel to do this? What is excel looking for when I use the code..
last_Row = Worksheets(dst_Sheet).Range("A65536").End(xlUp).Row
Bookmarks