userform with many Modes..

Hjemmet

Board Regular
Joined
Jun 20, 2018
Messages
207
On a userform i have these Function's
Combobox1
Labels 1 to 7
Textbox 1 to 10
and Commanbutton 1 to 7

I need the Combobox to Look on Range from Cell ("A1:A127") i get it to work on these Codeline

Code:
Private Sub UserForm_Initialize()'add column of data from spreadsheet to your userform ComboBox
ComboBox1.List = Sheets("Ark3").Range("A1:A127").Value


end Sub
But i can't figure out to get Value from Cell when Combobox1 is Set to "1" then Label1 set value from "B1" and Label2 set value From "D1"
and so on with Combobox1 from 1 to 127 Label1 and Label2 take value from B1 to B127 and D1 to D127

hope that was enough info
 
Ok i can see what you mean....

so i try to be more Specific this time...

All Labels on userform are Dependent on my Combobox1 witch is looking on Colomn A1 to A127


if Combobox1 is "1" then Label 1 and 3 and 5 and 7 should take Data from Colomn B1 (First Player Name)
and Label 2 and 4 and 6 and 8 should take Data from Colomn C1 (Second Player Name)
and Label 9 should take Data from Colomn D1 (name of Referee for Game)

Code:
      :    A      :     [COLOR=#000000]B[/COLOR]          :      C       :     D           :     E     :
    1:    1      :  [COLOR=#000000]Player 1[/COLOR]    :Player 2   : Referee 1    :            :
    2:    2      :  Player 3    :Player 4   : Referee 2    :            :
    3:    3      :  Player 5    :Player 6   : Referee 2    :            :
And so on to 127 
[COLOR=#ff0000]127:  127     : Player 33  :Player 85  : Refere 127 :            :[/COLOR]

the red line don't take notice of that the Player 33 isent player 127 and player 85 aint player 128
it's because it change after Game number 64 (64 game is 128 players)

hope that will give a Hint what i mean
 
Upvote 0

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
You can try this:

This only applies to 9 Labels.
I think you mentioned you may have up to 60 so this may cause you a lot more work.

I could see not trend so was not able to make a loop to do this.

Code:
Private Sub ComboBox1_Change()
'Modified  8/5/2019  3:41:36 AM  EDT
Dim ans As Long
ans = ComboBox1.ListIndex + 1
    With Me
        .Controls("Label1").Caption = Cells(ans, 2).Value
        .Controls("Label3").Caption = Cells(ans, 2).Value
        .Controls("Label5").Caption = Cells(ans, 2).Value
        .Controls("Label7").Caption = Cells(ans, 2).Value
                
        .Controls("Label2").Caption = Cells(ans, 3).Value
        .Controls("Label4").Caption = Cells(ans, 3).Value
        .Controls("Label6").Caption = Cells(ans, 3).Value
        .Controls("Label8").Caption = Cells(ans, 3).Value
        
        .Controls("Label9").Caption = Cells(ans, 4).Value
    End With
End Sub
 
Upvote 0
If you have a lot more then 9 you may want to use this way.

Code:
Private Sub ComboBox1_Change()
'Modified  8/6/2019  5:45:27 AM  EDT
Dim ans As Long
ans = ComboBox1.ListIndex + 1
With Control
    For Each Control In Me.Controls
        Select Case Control.Name
                
            Case "Label1", "Label3", "Label5", "Label7"
                .Caption = Cells(ans, 2).Value
    
            Case "Label2", "Label4", "Label6", "Label8"
                .Caption = Cells(ans, 3).Value
    
            Case "Label9"
                .Caption = Cells(ans, 4).Value
        End Select
   
    Next
End With
    
End Sub
 
Last edited:
Upvote 0
Thank you for that part
ive got it to work with your first code from #22
and figure out how to get the Rest of the labels from label 10 to 12
to work by your code
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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