Consulting

Results 1 to 3 of 3

Thread: Run-time error '1004': Application-defined or object-defined error

  1. #1

    Run-time error '1004': Application-defined or object-defined error

    Hi,

    I am getting this error in the last line. Please help.

    wb.Sheets("Final report").Range(Selection, Selection.End(xlDown)).Select
    Row4 = wb.Sheets("Final report").Range(Selection, Selection.End(xlDown)).Rows.Count
    Selection.Copy
    wb.Sheets("Template").Select
    Selection.PasteSpecial Paste:=xlPasteValues
    wb.Sheets("Final report").Select
    ActiveCell.Offset(0, 2).Select
    Range(ActiveCell, Cells(ActiveCell.Row + Row4, ActiveCell.Column)).Copy
    Thanks
    Last edited by rockybalboa; 11-19-2014 at 03:43 AM.

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    Works here as long as:
    1. wb is the currently active workbook
    2. SelectRow4 has a carriage return inserted between the t and the R
    3. Sheets("Final report") is active at the start of the code 's execution.
    4. When the line:
    Row4 = wb.Sheets("Final report").Range(Selection, Selection.End(xlDown)).Rows.Count
    is executed, Row4 is not assigned a number that when added to activecell.row on the last line, the result exceeds the number of rows on the sheet. This would typically occur when there is nothing below the selection when Row4 is being assigned a value.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    @p45cal Thank you. worked

Posting Permissions

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