anrion
Goto Top

ComboBox mit Variabler aus Makro verknüpfen

Hallo Forum,

Ich stocke momentan an einer Aufgabe:

Ich habe eine Combobox (Bild unten angehängt), welche mit den Items 0, 20, 40, 60, 80, 100 gefüllt ist.
With Me.ComboBox27
.AddItem "0"  
.AddItem "20"  
.AddItem "40"  
.AddItem "60"  
.AddItem "80"  
.AddItem "100"  
End With

Diese Werte sollen mit Ok bestätigt werden (Diesen Button habe ich noch nicht konfiguriert - weiß leider auch nicht wie man diese Bestätigung schreibt)
Nun sollen diese Werte einer Variablen zugeschrieben werden: z.B. Eingabe von ComboBox nach Bestätigung ist dann z.B. p

Dieses p soll dann in einem Makro hier eingreifen:
Cells(3, x) = 100

Also soll hier dann theoretisch stehen:
Cells(3, x) = p

Leider liegt das Makro in Modul2 und der Code für die ComboBox in dem Fenster (UserForm).
Desweiteren ist die ComboBox in dem 3. Fenster der Multiseiten.
Kann wer helfen?

Mit freundlichen Grüßen Stefan
forum

Content-Key: 312363

Url: https://administrator.de/contentid/312363

Printed on: April 23, 2024 at 09:04 o'clock

Mitglied: 129813
129813 Aug 11, 2016 updated at 11:07:59 (UTC)
Goto Top
Define a public variable in your sheet or module and assign it the value or directly assign the value of the combobox:
Cells(3, x).Value = Me.Combobox27.Value
Or create a public Function with a parameter and call it with your data as parameter value.

Regards

p.s. why don't you answer in your other questions ??
Member: Anrion
Anrion Aug 11, 2016 updated at 11:20:33 (UTC)
Goto Top
Thanks for the fast answer.

When i type this code instead of the Cells(3, x) = 100 then the debugger tells me that the Me is not correct
Do I Have to type sth. after the AddItems ?

And can you tell me how to confirm the Load of the Ok button? When I press it it doenst close.. only know that it close when unload Me but its the close button not the ok button.

p.s. They're good (Thanks a lot) but haven't got time last days to try that.
Mitglied: 129813
129813 Aug 11, 2016 updated at 11:32:16 (UTC)
Goto Top
Zitat von @Anrion:
When i type this code instead of the Cells(3, x) = 100 then the debugger tells me that the Me is not correct
Where do you write ? In the code of the form or anywhere else? The above works only on the form itself.
Do I Have to type sth. after the AddItems ?
Don't know what you mean, sorry.
And can you tell me how to confirm the Load of the Ok button? When I press it it doenst close.. only know that it close when unload Me but its the close button not the ok button.
What do you want to confirm? A msgbox should apear after you click on the OK Button ? Then in the click eventhandler of the button write
if msgbox("Do you want to commit the settings?",(vbQuestion or vbYesNo)) = vbYes then  
   me.hide
End if
Member: Anrion
Anrion Aug 11, 2016 at 11:50:04 (UTC)
Goto Top
In Which position exactly I have to put this in? I now have on top User Form and the part Initialize for the code above in my 1st article but I think I have to put your code in sth other or?
Mitglied: 129813
129813 Aug 11, 2016 updated at 11:54:07 (UTC)
Goto Top
I wrote
Then in the click eventhandler of the button
so double click on the button, then the code window with the eventhandler will pop up...