Avatar of angelfromabove
angelfromabove
Flag for United States of America asked on

I need a User Form to Input Data appear when a cell is clicked on

I had this question after viewing USER FORM TO INPUT DATA WHEN DOUBLE CLICK ON A CELL IN EXCEL.

I have a similar file  but I need a macro that will allow me to have more fields than the normal Excel form allows.   I need a form that will accommodate ~100 fields.  I would like the User to be able to click a cell with their name or e-mail address and a form pops up for them to input more information, which would populate on the same row as their name.
Microsoft ExcelMicrosoft Office

Avatar of undefined
Last Comment
Roy Cox

8/22/2022 - Mon
Roy Cox

I think 100 fields is a bit over the top. Do you have a table with 100 Columns in it?

This example will construct a UserForm with as many columns as your data has fields. It's basic but I was just experimenting with a dynamic userform
Martin Liss

Roy, you didn't attach your example.
angelfromabove

ASKER
Yes, my spreadsheet probably exceeds 100 fields.  It's an employee database, storing all sorts of information and access for each employee.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Roy Cox

Try again. Thanks Martin
Dynamic-UserForm.xlsm
angelfromabove

ASKER
Thank you!   A couple of things, I need code which will allow users to click on the row with their names and when it's clicked, a data form pops up, which will populate the data across the fields.  Are you able to provide that code? Secondly, your form only has 4 fields, how do you add more fields? As I mentioned, I need over 100  fields..
angelfromabove

ASKER
Disregard the 2nd part of that.  I just dragged the corners to expand the fields and it automatically adds them to the form.  Pretty Cool!  I just need the macro at this point.  Thanks!
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
angelfromabove

ASKER
Uh, never mind again, I see what this does now. Sorry, it pays to take time to review everything before I respond! This is great, let me fill in my data and test it and I'll be back to you, but looks like this might do the trick!
angelfromabove

ASKER
Quick question though, if I needed to tweak the form for certain users so they didn't see all of the fields, just maybe 20 or so, how could I do that, while still allowing all of the 100+ fields to remain on the spreadsheet? Thanks!
angelfromabove

ASKER
Ok, I've tested this with real data.   When I click "Maintain Client List"  and try to input new data into the fields, it doesn't populate the rows.  Nothing Changes.  Additionally, only the first field appears in the form, none of the other fields are populated in the field.  I copied and pasted my data over the columns in your sample, did that have anything to do with it?  Any suggestions?
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
angelfromabove

ASKER
On your sample, if I click New or Edit in the Data Form, it adds a new row.  I need the information to be entered on the same row.
Roy Cox

Can you attach an example of your workbook. The code for the button needs changing, but I need to see how you are using the form.

I woild suggest that you select a cell within an entry and get the line from that cell.
angelfromabove

ASKER
Here's a sample.  I need the ability to edit existing data on a row of data, not just add new data.  Additionally, per my question above, is it possible for the form to display fewer fields on the data form if necessary, without wiping them off of the spreadsheet?
Sample-Form2.xlsm
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Roy Cox

Now I have an example I'll see what i can do to create something more suitable
Roy Cox

Would you be displaying just the first 20 columns - A to T as the alternative?
angelfromabove

ASKER
Approximately that many columns, but I'll need it to be flexible so I can adjust as needed.
Your help has saved me hundreds of hours of internet surfing.
fblack61
Roy Cox

Just an up date. I have built in a way to select how many fields to display.It needs tidying up but I should be able to post a new form tomorrow.
angelfromabove

ASKER
Thanks, looking forward to it! Hoping to finish this up before the weekend!
Roy Cox

I've re-designed the original form. The activecell must be within the data before displaying the form.

1. You can now select how many columns to load
2. If the user selects > 20 then a password is required. Password is "secret"
3. There is an Edit Button.
4. If the check box is clicked a new entry can be added. Clear the checkbox and the selected row will be displayed for editing
Sample-Form3.xlsm
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
angelfromabove

ASKER
Thank you! This is awesome!  I love how many rows can be displayed! Couple of things:
1) I made sure that the checkbox was not clicked and I still can't edit.  I type over what's in the field on the form and it doesn't change the cell in the spreadsheet. I clicked "Done" and it still doesn't change.  
2) When I actually click the "Edit" button I get a macro error (see attached file):
Capture.PNG
angelfromabove

ASKER
Additionally, when I click the box which is supposed to add a new row, it doesn't add it to the bottom of the spreadsheet.  Nothing happens.
Roy Cox

I'll check it later, but ir was working fine for me
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
angelfromabove

ASKER
Not sure what the issues is, it appears to be pretty straightforward- can't imagine why it wouldn't work, but I attached the code.  Perhaps it's something I need to add to my VBA?  Not sure.
angelfromabove

ASKER
Seems to be getting hung up here:
Private Sub cmdEdit_Click()
    For Each oCtl In Me.Frame1.Controls
        If TypeName(oCtl) = "TextBox" Then Cells(lRw, CInt(oCtl.Tag)) = oCtl.Value
    Next oCtl
End Sub
End Sub
Roy Cox

This works, it edits and adds new. Originally I used to buttons but decided one would do. When I deleted the unused one I left an extra End Sub in, also I've changed a couple of lines

The Done button closes the form
Sample-Form3.xlsm
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
angelfromabove

ASKER
Looks Perfect! I tested it and it seems to work exactly as I envisioned!  

This is just a minor thing, if it can't be done, no worries, but if my cursor is in a blank row (not populated with data in the previous row), it says "No Data Detected Please Select a Cell Within the Table of Data".   I understand why the "Edit" function needs to be in the appropriate row, but is it possible to allow a row to be added beneath the last populated row regardless of where the cursor is? I'm afraid to ask, because everything else is so perfect now, I don't want that to break that, so if its too much of a headache, just let me know and I'll instruct the users.
Roy Cox

The cursor needs to be in the table so that the userform can recognize the address of the data. This could be avoided but the data would always need to start in the same row and the form would be less dynamic.

Another option would be to format the data as a Table then there would be an object to recognise.
Roy Cox

If the activecell is not in the data then the code assumes the data starts in A4, the form continues to load and will dispaly the first row of data.
Sample-Form3.01.xlsm
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
angelfromabove

ASKER
I'm not sure I understand your comment, are you saying that you did find a way to do what I needed in this new file? It sure looks that way when I tested it, just want to make sure nothing else changed and I'm understanding fully what this 2nd file does (or not).  I will wait to hear from you, but otherwise, I think this might do it.
Roy Cox

The userform needs to identify where the data is. That's why originally it required a cell within the data to be selected. I've changed it so that if the cell is not within the data then it will assume the data startes in A4 as in the example.
ASKER CERTIFIED SOLUTION
Roy Cox

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
angelfromabove

ASKER
Perfect, thank you! This is spot on! Love the additions! I also like that the data doesn't have to be in a table format and it still works.  Can you tell me how to change the name of the click button that says "Maintain Client List" I couldn't find it in the code.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
angelfromabove

ASKER
Never mind, I was finally able to click the Developer tab and modify the button, don't know why I couldn't before.  Thank you so much again!!!!! Here's your points!
angelfromabove

ASKER
This is the best solution ever, thank you so much!!! It was very appropriate and value added to my work!
Roy Cox

Pleased to help.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck