Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Jan 2002
    Location
    Cape Cod
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Copy Last Row (Excel2000)

    If you scan the enclosed code can you tell me if there is major error. If I open up two workbooks and try to copy the last row from one worksheet to another worksheet in another workbook is this code basically correct?
    I sent the attatchment using Word.
    Attached Files Attached Files

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 30 Times in 30 Posts

    Re: Copy Last Row (Excel2000)

    You check whether the source workbook sFile exists but you don't open it. If you assume that the currently open workbook is the source workbook there is no reason to check for its existence.

    You declare a variable iRowS but you don't assign a value to it, so its value remains 0. Hence the loop <code>For r = 2 To iRowS ... Next r</code> doesn't do anything.

  3. #3
    2 Star Lounger
    Join Date
    Jan 2002
    Location
    Cape Cod
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Copy Last Row (Excel2000)

    Hans, you said I declared a variable iRowS but didn't assign a value to it. I thought I put a value in it with the line :

    iRowS=wks.Cells(Rows.Count,1).End(xlUp).Row??

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 30 Times in 30 Posts

    Re: Copy Last Row (Excel2000)

    Yes, but that line comes AFTER the line For r = 2 To iRowS. So when For r = 2 To iRowS is evaluated, iRowS is still 0.

Posting Permissions

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