Copy from VBA combo box to sheet cell

Bozzy

New Member
Joined
Feb 21, 2011
Messages
8
If i have a combobox called 'cbTutor' in a form called 'frmNew' on vba on execl. How would i copy the data from that combobox and paste it into an empty cell (A6) on the spreadsheet when i click the submit button


i need to do this for multiple combo boxes and text boxes but im sure i can figure out how to do those after being given the code for this 1 thanks for any help
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
I take that back some reason the code:
Sheets("Overview").Select
cbTutor.Copy
Range("B6").Select
ActiveSheet.Paste

works fine but as soon as its a text box i copy from

The range is change to A6 and nothing else changes it doesnt work. whats wrong?
 
Upvote 0
Hi Bozzy,

Have you tried
Range("B6").Value = cbTutor.Value

If the combo box has two columns you could also try:
Range("B6").Value = cbTutor.List(cbTutor.ListIndex, 1)
The above gets the value from the 2nd (zero based) column of the combo box.

Hope that helps.
 
Upvote 0
Basically what it does is adds a new line, add's data into the new cells then sorts it, so if i simply told it to read from the cell it wouldnt work after sorting the data or adding a new line of data after in cell A6 as it would read the new information i input next time, not what i type in originaly the time before. so i preferably need it to copy and paste

Also i should add that if u use the same code for the text box that i used to copy and paste from the combo box it simply still copies and pastes from the 2nd combo box on my sheet rather than the text box even tho i changed the cbTarget.Copy (thats the name of the 2nd combo box, cbTutor is the first) to txtName it still does it =/
 
Last edited:
Upvote 0
I forgot that the procedure wouldnt be constantly running so it wouldnt always be setting the text box's value as A6 so yeah i took your idea in a more simple form which worked thanks :)

After a rather complicated sort system lol. your help was a great help thanks alot! :):)
 
Upvote 0

Forum statistics

Threads
1,224,608
Messages
6,179,872
Members
452,949
Latest member
Dupuhini

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