+ Reply to Thread
Results 1 to 10 of 10

Error msgs: "Object varible or with block variable not set"; "subscript out of range"

  1. #1
    Registered User
    Join Date
    10-25-2009
    Location
    Sofia, Bulgaria
    MS-Off Ver
    Excel 2003
    Posts
    14

    Error msgs: "Object varible or with block variable not set"; "subscript out of range"

    The following macro gives me two types of error messages:
    "object variable or with block variable not set" or "subscript out of range" on the first or the second line valFoundRow=...
    And I could not understand why...
    What I am trying to do is delete a couple of rows with unnecessary information, then copy the rest in different columns, not in one as they are now. I have no problem with the second part of the macro - it worked just fine before I added the part where the rows, containing "Share", "Save", "Email a Friend", "TRUE and the empty rows are supposed to be deleted.

    If anyone could help me with that, I would be really grateful...

    Please Login or Register  to view this content.
    Last edited by menyanthe; 10-26-2009 at 05:01 PM. Reason: code tags

  2. #2
    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: Problem with a macro

    Welcome to the forum.

    Plese take a few minutes to read the forum rules, and then edit your post to use CODE tags instead of QUOTE tags, and amend your thread title.

    Thanks.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    10-25-2009
    Location
    Sofia, Bulgaria
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Problem with a macro

    Hi, I have changed my quote tags to code tags, but first I don't see a way to amend my thread title, and second - what should I put for title?? I can't really put it shortly - if you have any ideas, I won't mind changing it
    Thanks.

    P.S. I just found it! It wasn't easy to put both error messages for title though - because the problem is I get them for practically the same thing and I don't know what triggers them.
    I am sorry for the mistakes I made while posting this thread - I am just over-exhausted at the moment...

    About the search engine - I have been searching similar issues with these two messages in the last 4 hours without any luck. Then I have tried finding different ways to delete certain rows based on certain conditions - but that led me to nowhere as well. That's why I decided I should look for some help from people who know much more than I do
    Last edited by menyanthe; 10-25-2009 at 06:26 PM. Reason: P.S.

  4. #4
    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: Problem with a macro

    The forum rules explain how to change your thread title.

    The exact error message is a very good thread title, both here and in using a search engine.

  5. #5
    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: Error msgs: "Object varible or with block variable not set"; "subscript out of ra

    Can you post an example of before and after, illustrating what the macro is supposed to do?

  6. #6
    Registered User
    Join Date
    10-25-2009
    Location
    Sofia, Bulgaria
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Error msgs: "Object varible or with block variable not set"; "subscript out of ra

    OK. This is Before and After for both Sheet1 and Sheet2.
    I am sorry for the low quality of the pictures.
    Attached Images Attached Images

  7. #7
    Registered User
    Join Date
    10-25-2009
    Location
    Sofia, Bulgaria
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Error msgs: "Object varible or with block variable not set"; "subscript out of ra

    OK, I am starting to get really confused now - I rewrote the code - to exclude some unintentional mistakes and here is what happened - it deleted rows it wasn't suppose to delete, deleted blank rows and none of the other rows. Also it gave me the same error as before - "object variable or with block variable not set" - only this time it was on the third valFoundRow line...
    Also I tried using this code, but it didn't seem to do anything at all. I guess I am missing something but can't figure out what...

    Please Login or Register  to view this content.
    Last edited by menyanthe; 10-26-2009 at 12:51 PM.

  8. #8
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,179

    Re: Error msgs: "Object varible or with block variable not set"; "subscript out of ra

    Are you missing a right bracket here?
    Please Login or Register  to view this content.
    Should be?
    Please Login or Register  to view this content.
    Regards

    Rick
    Win10, Office 365

  9. #9
    Registered User
    Join Date
    10-25-2009
    Location
    Sofia, Bulgaria
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Error msgs: "Object varible or with block variable not set"; "subscript out of ra

    Sorry, I just didn't copy it right...
    I corrected it now - it should be OK now.

  10. #10
    Registered User
    Join Date
    10-25-2009
    Location
    Sofia, Bulgaria
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Error msgs: "Object varible or with block variable not set"; "subscript out of ra

    I fixed it... I used the second code I posted... The problem actually was that the cells contained not only the text values but also some empty spaces - so it couldn't find the value. Also, the cells, containing text "TRUE" which I wanted to delete - probably there was a conflict with the VBA script - since True is commonly used in it (although it shouldn't be a problem since I put it in quotation marks, but I guess it is just a bug). So, I had to use the Find and Replace function in Excel (Ctrl+F) and replace "TRUE" with something else. I, personally, replaced it with "absurd".

    So, the problem was solved.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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