+ Reply to Thread
Results 1 to 20 of 20

Double click row to return data to userform for edit then return back to sheet

  1. #1
    Registered User
    Join Date
    01-20-2014
    Location
    York, England
    MS-Off Ver
    Excel 2013
    Posts
    21

    Angry Double click row to return data to userform for edit then return back to sheet

    Hi all!

    I thought I almost had this sorted...

    I am trying to create a data entry sheet to enter quotes on. When a quote is received, I click on my "Add quote" button and a userform appears. Data is entered into the userform (frmEntryForm) and returned back to the next available row.

    I also need to be able to:
    • Edit a row by double-clicking it. When a row is double-clicked, data from that row is passed back to the userform, edited and returned back to the same row (to prevent duplicates).
    • Validate that all fields are complete within the userform where relevant (i.e. if the work is not complete or in progress then the "Invoice Number" and "Actual Cost" fields are disabled and blanked to prevent entry (I think this is almost sorted judging by my tests)

    I have attached my sheet - the code is very messy (basic knowledge of VBA). Can someone tell me where I am going wrong?

    Thanks in advance!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Double click row to return data to userform for edit then return back to sheet

    Lots of errors (Sorry)

    Try changing these first:

    From
    Please Login or Register  to view this content.
    To
    Please Login or Register  to view this content.
    There are other issues...
    Please Login or Register  to view this content.
    No idea what this is supposed to represent. Perhaps
    Please Login or Register  to view this content.
    ...?

    And
    Please Login or Register  to view this content.
    As mentioned, Datarange is ambiguous so can't figure out what this should be...

    Probably more, but there's enough there to be going on with.

  3. #3
    Registered User
    Join Date
    01-20-2014
    Location
    York, England
    MS-Off Ver
    Excel 2013
    Posts
    21

    Re: Double click row to return data to userform for edit then return back to sheet

    Thanks for the reply Cytop.

    In reference to your points:

    It was supposed to be a range reference so basically if I double-click on a range anywhere between $A$4 and xlDown and xlRight (or K6 as it is on my attachment) then it brings up the userform containing data from that row. If the work has not been completed OR it's in progress, we shouldn't be invoiced for it therefore those fields are dependent on the value in cells under column G. This value will need to be changed to "Yes" once the work is complete and will be done from the userform.

  4. #4
    Registered User
    Join Date
    01-20-2014
    Location
    York, England
    MS-Off Ver
    Excel 2013
    Posts
    21

    Re: Double click row to return data to userform for edit then return back to sheet

    Quote Originally Posted by cytop
    To
    Please Login or Register  to view this content.
    Changed. This is supposed to be a range reference - so if I click in A4 then the results of A4 appear in the userform and I can edit them. If work is complete then I click on the relevant radio button, it changes the value to "Yes", it enables the Invoice Number and Actual Cost fields and dumps the values for those into the sheet. I also want a calculation field to be entered but I can do that.

    Quote Originally Posted by cytop
    There are other issues...
    Please Login or Register  to view this content.
    No idea what this is supposed to represent. Perhaps
    Please Login or Register  to view this content.
    ...?
    This was me trying to figure out how the code behaved. If I double-clicked in column G, it brought back everything in that row to the userform (which is great as that's what I want) however because I clicked in G, the "Work Complete" fields were available. This only applied to column G whereas I want it from A to the last cell.

    Quote Originally Posted by cytop
    And
    Please Login or Register  to view this content.
    As mentioned, Datarange is ambiguous so can't figure out what this should be...

    Probably more, but there's enough there to be going on with.
    Again me trying to work out how the code behaves.

    Appreciate everyones help on this...

  5. #5
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Double click row to return data to userform for edit then return back to sheet

    Ok, maybe this is presumptuous of me...

    Your Double Click event handler...
    Please Login or Register  to view this content.
    Your ShowForm procedure
    Please Login or Register  to view this content.
    A new procedure in the Quotes sheet class module
    Please Login or Register  to view this content.
    ValidateInput in Module1 is now a function
    Please Login or Register  to view this content.

    A new variable and Public Property in the userform
    Please Login or Register  to view this content.
    And, finally, the 'Submit' button Click event
    Please Login or Register  to view this content.
    That's my take on what you want to do. A little more writing needed to complete the UpdateCells procedure...
    Last edited by cytop; 01-30-2014 at 08:29 AM.

  6. #6
    Registered User
    Join Date
    01-20-2014
    Location
    York, England
    MS-Off Ver
    Excel 2013
    Posts
    21

    Re: Double click row to return data to userform for edit then return back to sheet

    Quote Originally Posted by Cytop
    Please Login or Register  to view this content.
    I added this.


    Quote Originally Posted by Cytop
    A new procedure in the Quotes sheet class module
    Please Login or Register  to view this content.
    I added this - Right-click on Quotes Sheet->Insert->Class Module

    Quote Originally Posted by Cytop
    A new variable and Public Property in the userform
    Please Login or Register  to view this content.
    Where do I add this? Is this a new sub? A new class module?

    Quote Originally Posted by Cytop
    And, finally, the 'Submit' button Click event
    Please Login or Register  to view this content.
    This bit has been added to my "Submit" button...

    It's just the public property bit I'm confused about...thanks again for your help!!

  7. #7
    Registered User
    Join Date
    01-20-2014
    Location
    York, England
    MS-Off Ver
    Excel 2013
    Posts
    21

    Re: Double click row to return data to userform for edit then return back to sheet

    Here is my sheet with what I could grasp from the above...
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    01-20-2014
    Location
    York, England
    MS-Off Ver
    Excel 2013
    Posts
    21

    Re: Double click row to return data to userform for edit then return back to sheet

    So far so good. Put all the bits of code you provided in the right areas but now I'm gettin a very bizarre error message when I click "Cancel":

    Run-time error '-2147418105 (80010007)'
    Automation error
    The callee (server [not server application]) is not available and disappeared; all connections are invalid. The call may have executed.
    When I debug, it goes to:

    Please Login or Register  to view this content.
    About to see what this error means but do you have any idea?

  9. #9
    Registered User
    Join Date
    01-20-2014
    Location
    York, England
    MS-Off Ver
    Excel 2013
    Posts
    21

    Re: Double click row to return data to userform for edit then return back to sheet

    It refers to something about "me.XXXX". Totally confused...

  10. #10
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Double click row to return data to userform for edit then return back to sheet

    Will get back to this a little later - on a phone at the moment but you probably unloaded the userform rather than my code doing it...

  11. #11
    Registered User
    Join Date
    01-20-2014
    Location
    York, England
    MS-Off Ver
    Excel 2013
    Posts
    21

    Re: Double click row to return data to userform for edit then return back to sheet

    OK, thanks a lot.

  12. #12
    Registered User
    Join Date
    01-20-2014
    Location
    York, England
    MS-Off Ver
    Excel 2013
    Posts
    21

    Re: Double click row to return data to userform for edit then return back to sheet

    OK, really confused now.

    I kept the ValidateInput code the same as you suggested however when I run this:

    Please Login or Register  to view this content.
    ...the error message pops up regardless of if txtCofelyReference.Value is blank or not.

  13. #13
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Double click row to return data to userform for edit then return back to sheet

    Try the attached.

    The original code I posted was written freehand and was untested - obviously there were 1 or 2 issues. Also, some of the mods you made had errors as well so I passed a train journey going through it...
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    01-20-2014
    Location
    York, England
    MS-Off Ver
    Excel 2013
    Posts
    21

    Re: Double click row to return data to userform for edit then return back to sheet

    Tested it at home and worked perfectly. There were a few type mismatch errors but I gave it a dry run and seemed OK after a while. I'll check it at work tomorrow but if it works there I owe you a cyber beer. Thank you so much for your help!

  15. #15
    Registered User
    Join Date
    01-20-2014
    Location
    York, England
    MS-Off Ver
    Excel 2013
    Posts
    21

    Re: Double click row to return data to userform for edit then return back to sheet

    Please Login or Register  to view this content.

  16. #16
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Double click row to return data to userform for edit then return back to sheet

    Is there a problem with that line...?

  17. #17
    Registered User
    Join Date
    01-20-2014
    Location
    York, England
    MS-Off Ver
    Excel 2013
    Posts
    21

    Re: Double click row to return data to userform for edit then return back to sheet

    Just got to work now and about to test it...

  18. #18
    Registered User
    Join Date
    01-20-2014
    Location
    York, England
    MS-Off Ver
    Excel 2013
    Posts
    21

    Re: Double click row to return data to userform for edit then return back to sheet

    Yeah, tried it and still getting a type mismatch but at work it's not letting me debug - at home last night it did and was giving the bit of code i posted above as the culprit!

  19. #19
    Registered User
    Join Date
    01-20-2014
    Location
    York, England
    MS-Off Ver
    Excel 2013
    Posts
    21

    Re: Double click row to return data to userform for edit then return back to sheet

    It's still being submitted by the way. It works within reason, just the type mismatch error...

  20. #20
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Double click row to return data to userform for edit then return back to sheet

    Remove that line - left in by mistake. The field is updated in the IF block above it.

    You should note this needs error handling added. The function CCUR() was used in case the users enter a £ sign in front of the numbers. CCUR will evaluate that correctly as a number but falls over if any other non-digit text is entered.

+ 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. Populate row value in userform textboxes, edit and save the changes back in sheet.
    By p_nayak268 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-29-2013, 07:48 PM
  2. vba cmd button to assign for edit section of textbox values return back to acurate cell
    By breadwinner in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-26-2013, 05:01 AM
  3. Populate Excel Userform with Sheet names with double click to open the sheet ??
    By Shacker in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 05-08-2013, 03:54 PM
  4. [SOLVED] Double click on filtered value pivot table value will return wrong data
    By macroqmm9 in forum Excel Charting & Pivots
    Replies: 6
    Last Post: 03-11-2013, 11:52 AM
  5. Replies: 7
    Last Post: 04-02-2012, 01:51 PM

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