+ Reply to Thread
Results 1 to 13 of 13

Userform - Search&Update ability

  1. #1
    Registered User
    Join Date
    03-18-2019
    Location
    Turkey
    MS-Off Ver
    Office 2016
    Posts
    4

    Question Userform - Search&Update ability

    Hello everyone, I'm quite new to VBA coding and thanks to my C&P/editing skills, I’ve managed to make an amateur CRM for my own needs in my company.

    ss.JPG

    I’ve come up with an user form(you can find its screenshot attached) which stores the data in one sheet(Maindata) and also creates a new another one(Sheet name is getting its name from center ID textbox- so its dynamic) which contains that center’s specific data and financial projections.

    Let me give you a brief overview of the spreadsheet;

    Maindata: Data entry starts from A2 and goes to AU2, (47 columns in total) the spreadsheet hasn’t populated yet, but when it does it will be probably +400 row long.

    Basically what I want to achieve is; Search&Update ability within user form. I can’t bring pre-registered data back to my user form. The search should bring partial matches as well, so there could be more than one registry when searched. To select the right one from search inquiry, I’ve added a list box that should give me the search results inside and when double-clicked, it should bring the whole row’s data back to user form. At the point of update, it should update/overwrite on the related row(Should not create a new registry) and it should update the dynamic named sheet’s(Which is created with the same name with “Center ID” back at the registry) specified cells.

    To be more specific with the search&update;
    1. A user will type into "textbox1"
    2. Hit search button which is called "cbSearch"
    3. Matching registries will be listed in "listbox1"
    4. Upon double-click userform will be filled with the selected registery info.(Listbox will show 4 cloumns of data but after dclick, the rest of the information will be shown on the userform)
    5. Update button should overwrite on the existing info on "maindata" sheet and the sheet that matches with it's center ID.

    If you can show me how to fill a textbox with the selected item's info from listbox I can adapt it to the rest of the 46 columns

    "A" column's info should go into = TB0 "B" column's info should go into = STN

    I'm putting the code of the save button which has the %90 of the code in the userform.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Userform - Search&Update ability

    Hi, welcome to the forum.
    Nice code you copied from somewhere. Now you want some else to create the form again and place all the code again and then help.
    Well, since you already have the form and the file.
    Please attach the file with the macros you have and maybe then somebody will pick it up to help.
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Registered User
    Join Date
    03-18-2019
    Location
    Turkey
    MS-Off Ver
    Office 2016
    Posts
    4

    Re: Userform - Search&Update ability

    Hello Keebellah, yes like I mentioned I've copied the base of the codes and edited according to my needs.

    Sure, you can find it attached!

    Thanks
    Attached Files Attached Files
    Last edited by Victusa; 03-19-2019 at 05:38 AM.

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Userform - Search&Update ability

    Okay, thanks, got the file will hold it against your request and see what I can do for you.

  5. #5
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Userform - Search&Update ability

    In the userform under search, what values would like to see to search on, you should populate it when the userform is opened so you can search as you type but right now you have all columns showing up.
    What are the criteria columns to search on?
    Hope I'm explaining myself so that you understand what I'm asking

  6. #6
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Userform - Search&Update ability

    I can see that you're quite new at VBA, the way you code everything, well we all started once and had to learn
    With the code written as it is you make it very difficult and I could put time into it and rewrite, but this is a help forum there is a separate section for commercial services if you really want someone to develop it for you.
    However I will make some minor modifications and try and give you some tips how to do some thing which you have made very complicated for yourself.
    I really admire your effort and am sure you picked up things from the internet and even tried by yourself.
    I still look for scripts and ideas how others do it, I am still learning every day (even after more than 40 years) and VBA is fun.
    You need two important things and I hope your boss will allow you: Time ( a lot of it), patience and imagination; time is what is really important especially when trying to figure out why something is not working
    If you answer the search question I asked previously I will see what I can do for you.

  7. #7
    Registered User
    Join Date
    03-18-2019
    Location
    Turkey
    MS-Off Ver
    Office 2016
    Posts
    4

    Re: Userform - Search&Update ability

    Quote Originally Posted by Keebellah View Post
    I can see that you're quite new at VBA, the way you code everything, well we all started once and had to learn
    With the code written as it is you make it very difficult and I could put time into it and rewrite, but this is a help forum there is a separate section for commercial services if you really want someone to develop it for you.
    However I will make some minor modifications and try and give you some tips how to do some thing which you have made very complicated for yourself.
    I really admire your effort and am sure you picked up things from the internet and even tried by yourself.
    I still look for scripts and ideas how others do it, I am still learning every day (even after more than 40 years) and VBA is fun.
    You need two important things and I hope your boss will allow you: Time ( a lot of it), patience and imagination; time is what is really important especially when trying to figure out why something is not working
    If you answer the search question I asked previously I will see what I can do for you.

    First of all, thank you for your time Keebellah it is much appreciated!

    I know it will be a long run but as you said, VBA is fun! Especially, when you see the outcome! For many people, I'm sure this whole thing can be done in an hour or so, but I'm learning a lot of things on the way so time isn't an issue.

    I want to run the search between A:D columns with a single textbox.

    The reason behind all columns are showing up is; I couldn't pick the rest of the data from the list box to textboxes by setting a range between A:D Because, after the search, the user should click on the desired registry from the listbox and the whole userform should be filled with the data. I could only achieve this with this code, so I was working on it.

    But, as you said, I think I've made it quite complicated for myself ha

  8. #8
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Userform - Search&Update ability

    Clear, I'll work with this and upload when I've got something to show, will be using a trick or two and will explain it so that you can see how I do it, I'm sure others will do it another way.
    In the meantime try this for the numeric textboxes instead

    Please Login or Register  to view this content.

  9. #9
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Userform - Search&Update ability

    I modified some things but there's a lot of work.
    Try it out and see if it works with more records in the main data sheet
    Attached Files Attached Files

  10. #10
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Userform - Search&Update ability

    I'm curious to read your findings.
    I have made more modifications such as updating an existing record, you will probably need to fine tune it.
    The Save button will save a new record and Update registry saves the selected record.

    The search inside the userform is dynamic and when you select a record it's loaded to the form.
    I also modified most of your numeric entries so that they only accept numbers.
    Enjoy and let me know

    I added an extra listbox that stores the selected record, will explain another time.
    The ListBox1 has 4 visible columns and one hidden, the first, this one stores the record's row number when reading an existing record

    If you look you will see that I reduce some routines to one to simplify the code (maintenance) like the transferring data from form to sheet is now one macro for both updating and adding a record

    You must however add a check if a sheet exits like the very hidden Final Look sheet

    Good-night
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    03-18-2019
    Location
    Turkey
    MS-Off Ver
    Office 2016
    Posts
    4

    Re: Userform - Search&Update ability

    I couldn't thank enough Keebellah, the form is way better now. Let me analyze the code you've modified and get back to you with my findings.

  12. #12
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Userform - Search&Update ability

    You've still have a lot to do

    Hope my codes help to build on

  13. #13
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Userform - Search&Update ability

    Am curious to know how you use the small Listbox you named lb
    Where and how is it filled?

+ 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/match two textboxes and then update that row
    By ckaten in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-30-2018, 09:48 AM
  2. [SOLVED] Userform - Search, Edit & Update
    By nancyching1711 in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 03-09-2018, 05:34 AM
  3. VBA userform search and update
    By Sazza in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 12-14-2016, 03:13 PM
  4. userform search and update
    By adamheon in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-17-2016, 02:13 AM
  5. Doing search and update in workbook with userform
    By jhinruiz28 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 12-04-2015, 03:13 AM
  6. Userform ADD/SEARCH/UPDATE Features
    By BARENTINEMATT in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-23-2015, 11:55 AM
  7. Do a search, display results in a userform with the ability to copy selected data.
    By blkmagik in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-05-2011, 04:40 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