Search and edit worksheets date by user form

Important Notice


Please note that on 14th December 2023 users will experience an expected outage whilst we make upgrades to our network. We anticipate this process may take a couple of hours and so we apologise in advance for any inconvenience.

  • Hi Dudes ,



    i have a user form that i use it to enter data in a worksheet ,


    Now i want to search and edit my data by this user form too, is it possible?



    here is the code :


  • Re: Search and edit worksheets date by user form


    Put this in the Worksheet Object Module for the sheet that gets updated by the User Form


    Now when you double click any cell in the row of data that needs to be edited the user form will show loaded with the required data from the selected row.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Re: Search and edit worksheets date by user form


    Further to my last reply you will also need to do the following.


    Add a new text box to your user form, make it with both BackColor and ForeColor set to the same BackColor as the User Form. That will make it invisible. Name the new text box "tbxRow".


    Then change part of your cmdAdd_Click code to this

    Code
    'find  first empty row in database
        iRow = ws.Cells(Rows.Count, 1) _
        .End(xlUp).Offset(1, 0).Row
        
         'Check if this is a row of data that is to be edited
         If tbxRow <> "" Then iRow = CLng(tbxRow)
         
         'check for a part number
        If Trim(Me.shsanad.Value) = "" Then


    Now if the user form was opened by doubleclicking a cell on the data sheet then that same row will get updated by the user form rather than a new row of data being added.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Re: Search and edit worksheets date by user form


    thanks a milion dear yegarboy , but i need it to work with my forms codes , beacause i only can edit this kind of lines :)) ; thanks dude

  • Re: Search and edit worksheets date by user form


    Quote from saeedabs;791980

    thanks a milion dear yegarboy , but i need it to work with my forms codes , beacause i only can edit this kind of lines :)) ; thanks dude



    any

  • Re: Search and edit worksheets date by user form


    When testing my code you did not change the name of the user form in the Worksheet Object Module code from "UserForm1" to "fish" which is what your user form is named. Also you did not add the new text box to your user form.


    I have made the necessary changes in the attached file. The code assigned to the user formm Add command button is now


    If you need to edit any of the data on the "Forms" sheet, double click any cell in the row of data that needs editing. The user form will open and will be populated with the data from the selected row. Open the user form via the button in the usual way to add new data.

  • Re: Search and edit worksheets date by user form


    :sheep: yepeeeeeeeee


    thanks a milioons dear kjbox




    another question ,


    i searched and i find this code for editing worksheet data by user form based on value that enter in a text box :



    as you see this code is retrieving data based on TextBox12 value in sheet1, and you can change them, but there is something verry annoying : for every textbox you want to add you have to enter next.next.next .... it made me crazy when i want to use 20 or more textboxes

  • Re: Search and edit worksheets date by user form


    You're welcome.


    Please ask your new question in a new thread with an appropriate thread title.


    Thank you.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!