Results 1 to 3 of 3

Excel thinks the last row is different than the last row.

Threaded View

  1. #1
    Forum Contributor
    Join Date
    04-11-2011
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    325

    Excel thinks the last row is different than the last row.

    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
    Last edited by 111StepsAhead; 04-12-2012 at 03:55 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1