Closed Thread
Results 1 to 5 of 5

object variable or with block variable not set

  1. #1
    Registered User
    Join Date
    03-20-2010
    Location
    Portugal
    MS-Off Ver
    Excel 2019
    Posts
    69

    object variable or with block variable not set

    Good morning,

    I am a little bit lost here, the code was working fine, I donīt remember changing anything, and suddenly now is giving error.

    Already spend a few hours around this matter and I still donīt understand why is giving this error.

    Run-time error '91':
    Object variable or With block variable not net



    Code:

    Private Sub CommandButton1EnviarEmail_Click()



    Dim answer As Integer



    NumRecibo = Folha9.Range("B13")
    ValorRecibo = Folha9.Range("J20")

    Dim foundRng As Range

    Dim QtMeses As String

    Set foundRng = Folha10.Range("A2:A400").Find(NumRecibo)




    QtMeses = foundRng.Offset(0, 10).Value ' <<<< The error is on this line


    If QtMeses <> Int(QtMeses) Then

    answer = MsgBox("Tem a certeza que pretende prosseguir com o valor irregular de " + FormatNumber(ValorRecibo, 2) + "€ ?" & vbCrLf & vbCrLf & "Referente a " + QtMeses + " Meses?", vbYesNo + vbQuestion, "Enviar PDF por Email")

    If answer = vbYes Then

    Call EscreverReciboEmailemPDF

    Exit Sub

    Else

    Exit Sub

    End If

    End If


    Call EscreverReciboEmailemPDF

    End Sub


    The main purpose of this code is to check a receipt number and then on that line with the "offset" method find a value to test if its "integer" or not "If QtMeses <> Int(QtMeses) Then" and then ask if the user wants to continue.
    Why does this "QtMeses" doesnīt keep the value returned by the offset ?

    Thank you for the help.

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,447

    Re: object variable or with block variable not set

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,884

    Re: object variable or with block variable not set

    Additionally, you have violated another one of our rules. Please take a few minutes to re-read the rules you agreed to abide by when you joined this forum.

    Administrative Note:

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    (Note: this requirement is not optional. No help to be offered until the link is provided.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  4. #4
    Registered User
    Join Date
    03-20-2010
    Location
    Portugal
    MS-Off Ver
    Excel 2019
    Posts
    69

    Re: object variable or with block variable not set

    Quote Originally Posted by alansidman View Post
    Additionally, you have violated another one of our rules. Please take a few minutes to re-read the rules you agreed to abide by when you joined this forum.

    Administrative Note:

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    (Note: this requirement is not optional. No help to be offered until the link is provided.)
    I was not aware, noted, thank you.

    Problem solved, wrong position of the cell B13.

    While trying to edit the first post following the forum rules, the screen becomes blank, it seems I am not able to edit or view the code that I had posted.
    Last edited by Blue_Wings; 08-23-2019 at 09:05 AM.

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,884

    Re: object variable or with block variable not set

    Since you have not bothered to comply with both moderator requests, this thread is now closed.

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. object variable or block variable not set Error message in Macro
    By loguraja10 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-25-2017, 09:01 AM
  2. [SOLVED] Run-time error '91': Object variable or With block variable not set when closing userform
    By bishoposiris in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-10-2016, 08:59 AM
  3. Replies: 2
    Last Post: 08-22-2014, 03:55 AM
  4. Replies: 4
    Last Post: 07-12-2013, 12:14 PM
  5. Replies: 6
    Last Post: 12-21-2012, 08:03 AM
  6. Replies: 1
    Last Post: 09-25-2012, 08:03 PM
  7. Error 91 object variable block variable not set when importing a CVS file
    By ReportBuilder2011 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-13-2011, 11:48 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