+ Reply to Thread
Results 1 to 10 of 10

End sub/with problem

  1. #1
    Forum Contributor
    Join Date
    08-08-2011
    Location
    Jacksonville, Florida
    MS-Off Ver
    Excel 2007
    Posts
    123

    End sub/with problem

    If I end the code with End Sub I get an error message that the program was expecting End With. When I use End With the program was expecting End Sub.

    Also within the following code can someone tell me exactly and only which lines to take out so the macro will stop counting empty cells. I only need to delete duplicate rows.

    Please Login or Register  to view this content.
    Last edited by dalewms2; 10-13-2011 at 03:10 PM.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: End sub/with problem

    dalewms2,

    You should be able to use the following to delete duplicates while ignoring blanks:
    Please Login or Register  to view this content.
    Last edited by tigeravatar; 10-13-2011 at 03:14 PM. Reason: User corrected code tags
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

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

    Re: End sub/with problem

    Your code tags are messed up, please correct.

    Your attached file does not have any code in it.

    I pasted your code above and it compiled and ran fine with no errors. Here is the (correctly formatted) version of what I actually ran:
    Please Login or Register  to view this content.
    I don't understand your second question. This code does not count empty cells.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: End sub/with problem

    Subs will always end with "End Sub", so that should always be there. What the error is telling you is that there is a With statement that does not have an End With. Since there is no With statement in your code, I can only assume that the problem lies elsewhere. I copied your code into a blank workbook and it compiled just fine. I threw together some dummy data and it ran fine for that as well.

  5. #5
    Forum Contributor
    Join Date
    08-08-2011
    Location
    Jacksonville, Florida
    MS-Off Ver
    Excel 2007
    Posts
    123

    Re: End sub/with problem

    Can someone tell me what's wrong when you open a spreadsheet and the macro is no longer there. I even opened the spreadsheet I attached to this question.

  6. #6
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: End sub/with problem

    My guess is that you saved it as an .xlsx and then saved it as a .xlsm.

  7. #7
    Forum Contributor
    Join Date
    08-08-2011
    Location
    Jacksonville, Florida
    MS-Off Ver
    Excel 2007
    Posts
    123

    Re: End sub/with problem

    Same macro. Different workbook. I am now getting a run time error 438 Object doesn't support this property at the point I highlighted below.


    Please Login or Register  to view this content.
    Attached Files Attached Files

  8. #8
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: End sub/with problem

    And this is why you should provide all your code.

    Here is your missing End With:
    Please Login or Register  to view this content.
    As for your error, your highlight does not show in a Code box. Please call the specific line out in its own code box.

  9. #9
    Forum Contributor
    Join Date
    08-08-2011
    Location
    Jacksonville, Florida
    MS-Off Ver
    Excel 2007
    Posts
    123

    Re: End sub/with problem

    This is the code that gives the error

    Please Login or Register  to view this content.

  10. #10
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: End sub/with problem

    This error is due to your missing End With I pointed out in my previous post.

    The sub is still in "With .Sort" mode, so

    Please Login or Register  to view this content.
    is really
    Please Login or Register  to view this content.
    Which is wrong.

+ 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