+ Reply to Thread
Results 1 to 19 of 19

Userform - Search, Edit & Update

  1. #1
    Forum Contributor
    Join Date
    04-20-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    135

    Userform - Search, Edit & Update

    Hi

    I want to enhance usage of my userform to be able to search, edit and amend/update the data in the excel worksheet.

    I am lost in between all the codes.

    Kindly assist me with the following:
    1) I want to search by "Identity No". Upon clicking the search button, all details will be populated in the userform for editing. However, I have a problem of populating the correct data when 1 person (with the sane identity number) has more than 1 record. Please assist me with the vba code for populating the userform after entering the date and identity number.

    2) Upon editing, how can I update/amend the data update clicking the update command button?

    Please refer to my attachment.

    Thank you for the assistance.

    Regards
    Nancy
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor ranman256's Avatar
    Join Date
    07-29-2012
    Location
    Kentucky
    MS-Off Ver
    Excel 2003
    Posts
    1,177

    Re: Userform - Search, Edit & Update

    it sounds like you are trying to do a lot of work you dont have to.
    Cant you just FILTER the Identity# on the sheet then alter the results?

  3. #3
    Forum Contributor
    Join Date
    04-20-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    135
    Quote Originally Posted by ranman256 View Post
    it sounds like you are trying to do a lot of work you dont have to.
    Cant you just FILTER the Identity# on the sheet then alter the results?
    Hi. Thank you for the advice. My original worksheet has alot of data with many columns and various excel formula. Thus, it will be easier for users to use the userform for editing. Please assist to resolve. Thank you.

  4. #4
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Userform - Search, Edit & Update

    1. 'Nullstring' is a reserved word in vba ('NullString' property), do not use it as a variable
    2. Correct the form, some labels ("Effection Date", "End Date") have been covered by 'MultiPage'
    3. Don't leave empty cells in place of 'No' - in the 'Vegetarian' column everything is filled out, and in others it is not, it makes a mess
    4. Collect the search results to the area variable and display them in the controls of the form using, e.g.: "SpinButton" - see attachment (I have not looked at macros for data updates in sheet)
    Attached Files Attached Files

  5. #5
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Userform - Search, Edit & Update

    Another way.
    Fill in Id No and click Search. Results appear in Listbox so you can see if there are multiple searchresults.
    In Listbox click on item to be amended.
    Make adjustments and click Update.
    Attached Files Attached Files
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  6. #6
    Forum Contributor
    Join Date
    04-20-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    135

    Re: Userform - Search, Edit & Update

    Hi bakerman2

    Your solution works great. However, I do not know how to apply to my original worksheet. Kindly explain the codes:

    Please Login or Register  to view this content.
    How do I interpret these numbers ie. 3, 1 & 11

    Please Login or Register  to view this content.
    What are the numbers denote?

    Thank you for the great help.

    Apologize for causing you so much trouble.

    Regards
    Nancy

  7. #7
    Forum Contributor
    Join Date
    04-20-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    135

    Re: Userform - Search, Edit & Update

    Hi Bakerman2

    Thank you for the solution and I managed to figure out the codes to apply back to my original worksheet except for 1 item.

    Please Login or Register  to view this content.
    The date on my original worksheet is at Column G (The trial worksheet is at column A). I do not know how to amend the code so that the correct data will apply in the listbox.

    Thank you for such a great solution.

    Regards
    Nancy

  8. #8
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: Userform - Search, Edit & Update

    try change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    txtDate is getting the information from item 5 in the Listindex of the ListBox. These start at "0" so "5" if the 6th column which is "G"

  9. #9
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Userform - Search, Edit & Update

    When you go into the properties of the ListBox, look at the Columnwidths.
    Every column you don't want to see is set to 0pts.
    Remember that LB-Columns are 0-based so Column A = 0, Column B = 1 so Column G would be 6
    If you have any other problems post an example file that reflects the true layout of your workbook.

  10. #10
    Forum Contributor
    Join Date
    04-20-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    135

    Re: Userform - Search, Edit & Update

    Hi

    I amended.

    However, after clicking the cmbSearch button, data /details in Column A is populated in the listbox.

    Which code I have to amend as such that Column G will be populated in the listbox of the userform.

    Thank you.

    Nancy

  11. #11
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: Userform - Search, Edit & Update

    This section of the cmdsearch button is loading the columns in order
    Please Login or Register  to view this content.
    you need to amend this order of calling of the data to change the order of the listbox

  12. #12
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Userform - Search, Edit & Update

    If you put this in Listbox properties ColumnWidhts it will show you Column C and Column G.
    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    04-20-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    135

    Re: Userform - Search, Edit & Update

    Hi

    Almost there. Much appreciated.

    One more problem; is the format of the date, both on the listbox and the userform.

    Currently the date appeared on the userform txtdate and listbox differ from the worksheet. That is, txtdate & listbox is 1 Mar 2018 but the actual date on the worksheet is 3 Jan 2018

    Thank you.

    Regards
    Nancy
    Attached Files Attached Files
    Last edited by nancyching1711; 03-07-2018 at 09:55 AM.

  14. #14
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: Userform - Search, Edit & Update

    Please Login or Register  to view this content.
    will correct the text box

    not sure of the syntax for the listbox

  15. #15
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Userform - Search, Edit & Update

    I've fixed all the coding but for the date part it seems to be regional setting because on my part all displays well.
    Try switching dd & mmm and check then.
    Attached Files Attached Files

  16. #16
    Forum Contributor
    Join Date
    04-20-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    135

    Re: Userform - Search, Edit & Update

    Hi

    I do not understand "try switching dd & mmm". May I know what do I have to do?

    Regards
    Nancy

  17. #17
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Userform - Search, Edit & Update

    Instead of
    Please Login or Register  to view this content.
    try
    Please Login or Register  to view this content.

  18. #18
    Forum Contributor
    Join Date
    04-20-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    135

    Re: Userform - Search, Edit & Update

    Hi

    Thank you for all the help.

    Regards
    Nancy

  19. #19
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Userform - Search, Edit & Update

    Glad to help and thanks for rep+.

+ 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. USERFORM : Search and edit data in userform
    By mohit.kumar9094 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-12-2018, 07:50 AM
  2. [SOLVED] VBA Userform - Search, Edit & Update functionality
    By camp2chiawa in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 03-15-2016, 03:43 AM
  3. How to update data's by using VBA userform also edit by Sl. No
    By Nisar.mohammed in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-27-2015, 10:38 AM
  4. [SOLVED] VBA Userform Edit/Update record help
    By sa.1985 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-20-2013, 10:29 AM
  5. update value and edit items already update on sheet by userform
    By tjxc32m in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 11-08-2013, 10:13 AM
  6. edit data in userform and update spreadsheet
    By nunans in forum Excel General
    Replies: 2
    Last Post: 03-08-2012, 04:44 AM
  7. Edit/Update list from userform (auto alphabetized)
    By Jogier505 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 12-07-2009, 06:28 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