+ Reply to Thread
Results 1 to 6 of 6

userform finds and updates data line- object variable error

  1. #1
    Registered User
    Join Date
    01-25-2016
    Location
    Colorado
    MS-Off Ver
    2013
    Posts
    3

    userform finds and updates data line- object variable error

    Hello,
    I am having issues with a userform that saves edits to an existing inventory line in a file.

    the userform uses a combobox to select the client name from column A, and the "save" sub is supposed to find the client row and replace cell values with whatever was entered on the form textboxes

    however i get an "object variable or with block variable not set" on the first foundcell that I can't figure out.

    Here is the code
    Please Login or Register  to view this content.
    Any idea what I did wrong?

  2. #2
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: userform finds and updates data line- object variable error

    Almost assuredly it is because foundcell is Nothing, i.e. your .Find didn't find anything, so there is nothing to offset. You can remedy this situation by doing this:

    Please Login or Register  to view this content.
    But I think your larger question would be why you're not finding anything, but that I can't address without seeing your worksheet.
    I'm interested in starting a career working with VBA, if anyone knows of any opportunities!

  3. #3
    Registered User
    Join Date
    01-25-2016
    Location
    Colorado
    MS-Off Ver
    2013
    Posts
    3

    Re: userform finds and updates data line- object variable error

    Thanks for the quick reply!

    since the combo-box is pulling from column A and the search is of column A, it should technically always find itself.


    Here is the file attached (Userform 4 and the save button is the issue one)


    Thanks
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: userform finds and updates data line- object variable error

    It's because you have Formulas in column A, which .Find is going to look at by default unless you tell it not to. So it tried to match the string in your combo box to the formulas in column A, and of course found no matches. So you need to tell it to look at the values the formulas create. Using this line below, it did find matches.

    And it's still good practice to use my suggestion above, so you don't error out when there are no matches. You could also add an Else statement to that with a msgbox of "no matches found" or whatever.

    Please Login or Register  to view this content.

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: userform finds and updates data line- object variable error

    You don't need to use Find to get the row of the selected client in the combobox, you can use the combobox's ListIndex property.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  6. #6
    Registered User
    Join Date
    01-25-2016
    Location
    Colorado
    MS-Off Ver
    2013
    Posts
    3

    Re: userform finds and updates data line- object variable error

    That's perfect, both solutions worked!
    Thank you for the help

+ 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. Find in VBA finds first instance of similar object being searched but not exact object
    By xcelnovice101 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-14-2015, 01:10 PM
  2. Replies: 2
    Last Post: 08-22-2014, 03:55 AM
  3. [SOLVED] New Error/Old Code - Run Time Error 91; Object variable or With block variable not set
    By humboldtguy in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-15-2014, 12:39 AM
  4. Replies: 6
    Last Post: 12-21-2012, 08:03 AM
  5. Replies: 1
    Last Post: 09-25-2012, 08:03 PM
  6. 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
  7. Object Variable Not Set Error on Selection object
    By Jean in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-24-2006, 01:50 PM

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