+ Reply to Thread
Results 1 to 3 of 3

Macro works, but not when I run it (error 91)

  1. #1
    Registered User
    Join Date
    05-08-2019
    Location
    São Paulo, Brasil
    MS-Off Ver
    16
    Posts
    2

    Macro works, but not when I run it (error 91)

    Hello guys"

    I'm using this code below for an automatic email to be send 7 days prior to the due date (ron de bruin's one) and it's working when i change the dates, when i use the sheet 7 days prior, but if I have that sheet open and try running the macro using "f9" or clicking "run" it gets me an error 91 on the following line and i'd like some help fixing it, since i've looked up on all the internet and couldn't get it to run properly. Also, if i erase this line giving me an error, the macro runs:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    The mail code module is this one:

    Please Login or Register  to view this content.

  2. #2
    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 works, but not when I run it (error 91)

    First, I do not understand how your first sub compiles with Option Explicit because Formula Cell is undeclared.

    Second, I see a problem, and I will suggest a solution, but I cannot test this without your file and some sample data.

    The variable FormulaCell is undeclared, but it is assigned in your first Sub. It is used in your second sub, but because it is undeclared your second sub doesn't know about it. When your second sub encounters it, it has not been set, but you are trying to use it as a Range, and so you get Error 91, which means "object variable not set."

    To fix this, pass a parameter to the second sub.

    Please Login or Register  to view this content.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    05-08-2019
    Location
    São Paulo, Brasil
    MS-Off Ver
    16
    Posts
    2

    Re: Macro works, but not when I run it (error 91)

    Thanks very much, specially for the quick responde! Your suggestions did stop error 91 from coming, but now, the macro list is empty, so i'm guessing something got redefined there! Was that supposed to happen?

+ 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. Line in macro works sometimes, other times I get error
    By amycat81178 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-22-2018, 05:15 PM
  2. [SOLVED] .Match with On Error: On Error Resume Next works. On Error GoTo only works once. Err.Clear
    By Doc.AElstein in forum Excel - New Users/Basics
    Replies: 28
    Last Post: 03-16-2015, 12:55 PM
  3. Problem: Save As Macro that works, but end file has an error
    By Monistw in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-15-2014, 10:39 AM
  4. [SOLVED] This macro works... kind of. Please spot my error.
    By Alias1431 in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 01-10-2014, 02:31 PM
  5. [SOLVED] Macro error when ran on multiple sheets on workbook (even though macro works)
    By steven_e in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-02-2012, 06:09 PM
  6. [SOLVED] Runtime error for macro that works in workbook created in
    By Crystal in forum Excel General
    Replies: 1
    Last Post: 06-22-2005, 04:05 PM
  7. Macro works in XL 2k3 but error in older version
    By bill_s1416 in forum Excel General
    Replies: 1
    Last Post: 01-04-2005, 04:00 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