Saving data form userform

Will98

New Member
Joined
Dec 11, 2020
Messages
5
Office Version
  1. 2019
Platform
  1. Windows
I created a userform with 10 comboboxes and labels
I have tried saving the results onto another spreadsheet "Code" but only the first two comboboxes save and the second one only changes when the first box is empty.
The code i am using is below
Private Sub CommandButton1_Click()
With Worksheets("Code")
.Cells(3, 2).Value = UserForm1.ComboBox11.Value
.Cells(4, 2).Value = UserForm1.ComboBox12.Value
.Cells(5, 2).Value = UserForm1.ComboBox13.Value
.Cells(6, 2).Value = UserForm1.ComboBox14.Value
.Cells(7, 2).Value = UserForm1.ComboBox15.Value
.Cells(8, 2).Value = UserForm1.ComboBox16.Value
.Cells(9, 2).Value = UserForm1.ComboBox17.Value
.Cells(10, 2).Value = UserForm1.ComboBox18.Value
.Cells(11, 2).Value = UserForm1.ComboBox19.Value
.Cells(12, 2).Value = UserForm1.ComboBox20.Value
End With
End Sub
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
So your saying you have a value in all these Comboboxes but the values are not entered into the cells when you click on a button?
And you have a worksheet named Code.

I see no reason why your script would not work.
 
Upvote 0
yes
its sent up so that once you fill in the comboboxes and click the commandbutton1 it saves it to the code excelsheet
but it does work and i dont know why
 
Upvote 0
yes
its sent up so that once you fill in the comboboxes and click the commandbutton1 it saves it to the code excelsheet
but it does work and i dont know why
I suggest you shorten the code to just one combobox and if that works try doing the next one till you discover what is wrong.

I'm surprised you need nearly 20 comboboxes.
 
Upvote 0
the first 10 are on a different userform
it works when its just one code line, i tried before that why i am confused
 
Upvote 0
the first 10 are on a different userform
it works when its just one code line, i tried before that why i am confused
I thought we were working with 1 Userform with a Multipage which has several Multipage Pages

But your now saying:
the first 10 are on a different userform
A different Userform or a different Userform Multipage Page.

I still do not know what the ultimate Goal here is what you said in first post:
I have tried saving the results onto another spreadsheet "Code" but only the first two comboboxes save and the second one only changes when the first box is empty.

If the comboboxes are on different multipage pages you have to tell the script that.


Like this:
VBA Code:
Private Sub CommandButton2_Click()
'Modified  12/12/2020  12:01:47 PM  EST
Cells(1, 2).Value = MultiPage1.Page1.ComboBox1.Value
Cells(1, 3).Value = MultiPage1.Page2.ComboBox2.Value

End Sub
 
Upvote 0
they were on a draft userform i created at first but i have deleted that and now the comboboxes run from combobox 1 to combobox10.
the aim is to save the results from the userform1 into the spreadsheet "code"
 
Upvote 0
they were on a draft userform i created at first but i have deleted that and now the comboboxes run from combobox 1 to combobox10.
the aim is to save the results from the userform1 into the spreadsheet "code"
You are going to have to be more specific.
You said:
the aim is to save the results from the userform1 into the spreadsheet "code"
And that is what your original code in post1 should do.
 
Upvote 0
yes but the code is only saving the results from the first and second comboboxes
 
Upvote 0
yes but the code is only saving the results from the first and second comboboxes
I have no ideal

You showed:
Cells(3, 2).Value = UserForm1.ComboBox11.Value
.Cells(4, 2).Value = UserForm1.ComboBox12.Value
.Cells(5, 2).Value = UserForm1.ComboBox13.Value
.Cells(6, 2).Value = UserForm1.ComboBox14.Value

Why start with Combobox11
What is happening with Combobox1

And where are these Comboboxes. Are they on Userform1

Are you using a Multipage Page?

And what does this mean?
You said:

the first 10 are on a different userform
it works when its just one code line, i tried before that why i am confused

This is very confusing.
You have more then one UserForm and want to put code in one of them?
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,942
Members
449,094
Latest member
teemeren

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