+ Reply to Thread
Results 1 to 16 of 16

Any Reason why my lastrow syntax works on one wookbook and not another

  1. #1
    Registered User
    Join Date
    09-20-2012
    Location
    New york
    MS-Off Ver
    Excel 2003
    Posts
    45

    Any Reason why my lastrow syntax works on one wookbook and not another

    I am getting a object required error but when I use the same syntax changing the name of the work sheet in another workbook it works fine. Below is the syntax I am using to find the last row.

    Please Login or Register  to view this content.
    Other than the worksheet name everything is generic and should work for both sheets.
    Attached Files Attached Files
    Last edited by Darthzo; 04-30-2015 at 04:32 PM.

  2. #2
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: Any Reason why my lastrow syntax works on one wookbook and not another

    Do they both have the tab called "Report" as that would cause issues?
    Please ensure you mark your thread as Solved once it is. Click here to see how.
    If a post helps, please don't forget to add to our reputation by clicking the star icon in the bottom left-hand corner of a post.

  3. #3
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Any Reason why my lastrow syntax works on one wookbook and not another

    Hi Darthzo

    What error are you getting?
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  4. #4
    Registered User
    Join Date
    09-20-2012
    Location
    New york
    MS-Off Ver
    Excel 2003
    Posts
    45

    Re: Any Reason why my lastrow syntax works on one wookbook and not another

    I actually changed the worksheet just to test the command to Report(Mike). I am getting a object required error (jaslake).

  5. #5
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Any Reason why my lastrow syntax works on one wookbook and not another

    Hi Darthzo

    Check for trailing (or leading) spaces in the Sheet Name..."Report" vs " Report" vs "Report "

  6. #6
    Registered User
    Join Date
    09-20-2012
    Location
    New york
    MS-Off Ver
    Excel 2003
    Posts
    45

    Re: Any Reason why my lastrow syntax works on one wookbook and not another

    I have attached the workbook. There are no spaces in the workbook name.

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Any Reason why my lastrow syntax works on one wookbook and not another

    It works fine for me, but it's an undeclared variable so there is no communication to the routine that needs it. Change

    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    ... and the routine to

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  8. #8
    Registered User
    Join Date
    09-20-2012
    Location
    New york
    MS-Off Ver
    Excel 2003
    Posts
    45

    Re: Any Reason why my lastrow syntax works on one wookbook and not another

    I made the changes you suggested but come up with an error once I added the new sub(shg).
    Attached Files Attached Files

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Any Reason why my lastrow syntax works on one wookbook and not another

    What error, what line of code?

  10. #10
    Registered User
    Join Date
    09-20-2012
    Location
    New york
    MS-Off Ver
    Excel 2003
    Posts
    45

    Re: Any Reason why my lastrow syntax works on one wookbook and not another

    This line is highlighted red

    Please Login or Register  to view this content.

  11. #11
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Any Reason why my lastrow syntax works on one wookbook and not another

    Oops:

    Please Login or Register  to view this content.
    As simple-minded as it is, though, I'd skip the function and put the code in line:

    Please Login or Register  to view this content.
    Last edited by shg; 04-30-2015 at 05:54 PM.

  12. #12
    Registered User
    Join Date
    09-20-2012
    Location
    New york
    MS-Off Ver
    Excel 2003
    Posts
    45

    Re: Any Reason why my lastrow syntax works on one wookbook and not another

    I am getting a Run-time error '424: when I run the last bit of code you posted. To make sure it's not my setting I will run this from another computer. Also are you able to run this in the attached workbook. I have used this syntax many time in the past and cannot see why it won't work just in this workbook for me.

  13. #13
    Registered User
    Join Date
    09-20-2012
    Location
    New york
    MS-Off Ver
    Excel 2003
    Posts
    45

    Re: Any Reason why my lastrow syntax works on one wookbook and not another

    Do you know what reference are standard for VBA I see a Personal one in my list this causes an error for me though when I enable it.

  14. #14
    Registered User
    Join Date
    09-20-2012
    Location
    New york
    MS-Off Ver
    Excel 2003
    Posts
    45

    Re: Any Reason why my lastrow syntax works on one wookbook and not another

    Not sure why but this one seems to work where the other does not. Is there something that special cells detects that the regular syntax does not?

    Please Login or Register  to view this content.

  15. #15
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Any Reason why my lastrow syntax works on one wookbook and not another

    Do you use Excel 2003 or later version? If it is later it is better to use sheet object for Rows property also:
    Please Login or Register  to view this content.
    Also it is better to use Workbook object for the Worksheet.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  16. #16
    Registered User
    Join Date
    09-20-2012
    Location
    New york
    MS-Off Ver
    Excel 2003
    Posts
    45

    Re: Any Reason why my lastrow syntax works on one wookbook and not another

    I am using excel 2010. I actually found the issue. In the declaration I had Rows as a variant. This seem to cause all the issues. Changed the variable to Rws and works fine now.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Get LastRow using "Find" only works for Col A
    By capson in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-20-2015, 11:43 AM
  2. [SOLVED] if then loop works incorrectly - syntax?
    By canoehack in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-25-2013, 09:31 AM
  3. [SOLVED] How does copy value only syntax works?
    By AB33 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-29-2012, 03:44 AM
  4. Copy From LastRow to LastRow+7
    By dvent in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-11-2010, 06:56 AM
  5. Only CreateObject Syntax works.
    By Boomessh in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-07-2005, 09:07 AM

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