Userform data entry into excel

austin397

New Member
Joined
Dec 16, 2016
Messages
36
Hello all,

I am attempting to have my userform enter data into certain cells on my spreadsheet. I need it to enter the data from a text box into a cell. The cell that it goes into depends on the data selected from a list box.

So if in the list box I select the option of "8605", and in the text box is the data "52" then I need it to look at Column A and if it find a match in column A that is "8605", then enter "52" in the cell of the same row and in column D.

In this instance it would find "8605" in cell A193. So in cell D193 I need it to enter "52".

Please help!
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
I need to make a few assumptions

1) if the option (selected from the list box) is not found then do nothing
2) Column A contains zero cells that are BLANK; hence the first BLANK cell encountered means we have reached the end of list
3) The search and entry actions will be initiated by a click on an ENTRY button.

I will test my solution and be back with you within the next 2 hours.
Please let me know if my assumptions are OK with you, and/or you have additional requirements
 
Upvote 0
need
Code:
application.match(listboxvalue, sheet#.range("A:A"),0)
This would give you the row number of 8605 for example. I've provided no error checking in case 8605 doesn't exist.
 
Upvote 0
Additional assumptions

4) Column A contains unique values. The routine will NOT make entries on every row with a match; just the first row.
5) You are familiar with UserForms, and know how to add buttons, textboxes, and such
 
Upvote 0
Hello dssJones and Roderick,

Thank you for your replies.

As far as your assumptions
1) That is correct.
2) Column A does contain blank cells but the list does not end at the first blank cell. The data goes until row 300 but there are blanks withen where the data has been seperated for organization reason.
3) That is correct.
4) That is correct.
5) That is correct.

I need to make a few assumptions

1) if the option (selected from the list box) is not found then do nothing
2) Column A contains zero cells that are BLANK; hence the first BLANK cell encountered means we have reached the end of list
3) The search and entry actions will be initiated by a click on an ENTRY button.

I will test my solution and be back with you within the next 2 hours.
Please let me know if my assumptions are OK with you, and/or you have additional requirements
Additional assumptions

4) Column A contains unique values. The routine will NOT make entries on every row with a match; just the first row.
5) You are familiar with UserForms, and know how to add buttons, textboxes, and such

Thank you for this Roderick, that is useful information.
need
Code:
application.match(listboxvalue, sheet#.range("A:A"),0)
This would give you the row number of 8605 for example. I've provided no error checking in case 8605 doesn't exist.
 
Upvote 0
Simply:
Code:
rng = "D" & [COLOR=#333333]application.match(listboxvalue, sheet#.range("A:A"),0)[/COLOR]
sheet1.range(rng) = Userform1.textbox1
 
Upvote 0
Hello Roderick_E,

Thank you for the reply, I tried this and kept getting the error "Type mismatch".

Simply:
Code:
rng = "D" & [COLOR=#333333]application.match(listboxvalue, sheet#.range("A:A"),0)[/COLOR]
sheet1.range(rng) = Userform1.textbox1
 
Upvote 0
Well hopefully you adjusted my code :-)
Depending which sheets you are using, something like:

rng = "D" & application.match(Userform1.listbox1.value, sheet1.range("A:A"),0)
sheet1.range(rng) = Userform1.textbox1
 
Upvote 0
Yes, I adjusted the sheets and other applicable names. Still gives "Type mismatch" error.

Code:
rng = "D" & Application.Match(StandardChannel.Channel.Value, Sheet1.Range("A:A"), 0)   
 Sheet1.Range(rng) = StandardChannel.dShallow
 
Last edited:
Upvote 0
Yes, I adjusted the sheets and other applicable names. Still gives "Type mismatch" error.

Code:
rng = "D" & Application.Match(StandardChannel.Channel.Value, Sheet1.Range("A:A"), 0)   
 Sheet1.Range(rng) = StandardChannel.dShallow


Sometimes you have to Dim out the other parts, something like

Code:
Schan = StandardChannel.Channel.Value
rng = "D" & Application.Match(Schan, Sheet1.Range("A:A"), 0)   
Sheet1.Range(rng) = StandardChannel.dShallow

You might want to check what is being returned by StandardChannel.dShallow
msgbox StandardChannel.dShallow
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,719
Messages
6,174,089
Members
452,542
Latest member
Bricklin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top