+ Reply to Thread
Results 1 to 4 of 4

Object variable or With block variable not set Error during sorting program

  1. #1
    Registered User
    Join Date
    04-17-2012
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    7

    Object variable or With block variable not set Error during sorting program

    Hi,

    I'm a complete noob at VBA, and I cannot figure out why I am getting this error while trying to sort a list of numbers. I am trying to use ".Find" to select the maximum value in column H and then cut the row with this max value and the row above it into a new sheet. This process seems to work for most sets of numbers, but for some reason, with the particular set listed in the file, I get the error mentioned in the title. Obviously I am not setting something correctly, but I am not sure which variable needs to be set, and why some lists of numbers work whereas this particular one doesnt.

    file is attached


    Thanks
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Object variable or With block variable not set Error during sorting program

    It appears to be because the .Find isn't finding a match, even though the value exists ... probably something to do with the value not being exactly as displayed.

    Changing the line where you set dMax to:

    Please Login or Register  to view this content.
    Seems to fix it.

  3. #3
    Registered User
    Join Date
    04-17-2012
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Object variable or With block variable not set Error during sorting program

    Thanks for that Andrew - works a charm.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Object variable or With block variable not set Error during sorting program

    What are you trying to do? If you are sorting numbers then use Sort
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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