+ Reply to Thread
Results 1 to 4 of 4

macro used to work but now runtime error 1004

  1. #1
    Registered User
    Join Date
    05-04-2015
    Location
    Irvine, CA
    MS-Off Ver
    2010
    Posts
    37

    macro used to work but now runtime error 1004

    My macro has been working fine for months but just crashed today. I don't find anything noticeable about the files that has changed. it crashes at the line that counts the number of rows. Any idea what's wrong? I have tried different ways of writing it as well but it crashes at "Lstrow ="...Below is the original code:
    HTML Code: 

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: macro used to work but now runtime error 1004

    It works for me, I had to change a few things to make it run on my pc.

    Please Login or Register  to view this content.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: macro used to work but now runtime error 1004

    I don't know why it used to work and now does not, but I see a likely problem. In the line of code getting the error, put a "." before "Rows.Count". Without the dot, VBA assumes that Rows.Count refers to the active sheet. So this works only if wb1.Sheets(1) is the active sheet, and there is nothing in the code to guarantee that is the case.

    I am still not sure why that would raise an error but the best practice is to fix everything you know is wrong then see what problems are left.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Registered User
    Join Date
    05-04-2015
    Location
    Irvine, CA
    MS-Off Ver
    2010
    Posts
    37

    Re: macro used to work but now runtime error 1004

    yes the . before the rows fixed the issue. i'm not sure why it was fine before. thanks a lot!

+ 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. keep getting Runtime error 1004 in my VBA Macro and not sure why
    By Pimp_mentality in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-03-2015, 04:29 PM
  2. Runtime Error 1004 on list creating macro
    By taipalam in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-03-2014, 04:13 AM
  3. [SOLVED] Advanced Filtering -Runtime Error 1004. Cannot figure out why will not work.
    By thelisa in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-24-2013, 08:00 AM
  4. Simple Activesheet.paste will not work (Runtime 1004 error)
    By yjung15 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-16-2013, 02:42 PM
  5. Macro - Runtime Error 1004
    By Evian in forum Excel Charting & Pivots
    Replies: 10
    Last Post: 10-08-2008, 04:54 AM
  6. [SOLVED] Excel 2003 Macro Error - Runtime error 1004
    By Cow in forum Excel General
    Replies: 2
    Last Post: 06-07-2005, 09:05 AM
  7. naming tab macro error runtime error 1004
    By D in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-27-2005, 10:06 PM

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