Im fairly new to VBA so apologies for any ridiculous looking script. Basically I was asked to create a room plan for the office i work in. I have done this using Excel 07 VBA. I have a userform with a button for each desk, when a button is clicked it gets the details from 6 different combo boxes and shows the details of that desk in a textbox.Each button is named the number of the desk i.e 1,2,3....upto 87.
Everything works fine, although i have had to put the following code under each button_click function
Private Sub CommandButton9_Click()
ComboBox1.ListIndex = 8
ComboBox2.ListIndex = 8
ComboBox3.ListIndex = 8
ComboBox4.ListIndex = 8
ComboBox5.ListIndex = 8
ComboBox6.ListIndex = 8
TextBox2.Value = "Desk = " & ComboBox1.Value & vbCr & "User = " & ComboBox2.Value & vbCr & "User ID =" & ComboBox6.Value & vbCr & "Telephone Port = " & ComboBox3.Value & vbCr & "Extension = " & ComboBox4.Value & vbCr & "Network Port = " & ComboBox5.Value
so i have the above 87 times. Each time changing the list index so button 1 listindex = 0 button 2 = 1 etc.
What i would like is the above code to be written once and the listindex changes according to what button is clicked. I have checked various forums/threads but cant find an answer
Thanks in advance <!-- / message --><!-- BEGIN TEMPLATE: ad_showthread_firstpost_sig --><!-- END TEMPLATE: ad_showthread_firstpost_sig -->
Everything works fine, although i have had to put the following code under each button_click function
Private Sub CommandButton9_Click()
ComboBox1.ListIndex = 8
ComboBox2.ListIndex = 8
ComboBox3.ListIndex = 8
ComboBox4.ListIndex = 8
ComboBox5.ListIndex = 8
ComboBox6.ListIndex = 8
TextBox2.Value = "Desk = " & ComboBox1.Value & vbCr & "User = " & ComboBox2.Value & vbCr & "User ID =" & ComboBox6.Value & vbCr & "Telephone Port = " & ComboBox3.Value & vbCr & "Extension = " & ComboBox4.Value & vbCr & "Network Port = " & ComboBox5.Value
so i have the above 87 times. Each time changing the list index so button 1 listindex = 0 button 2 = 1 etc.
What i would like is the above code to be written once and the listindex changes according to what button is clicked. I have checked various forums/threads but cant find an answer
Thanks in advance <!-- / message --><!-- BEGIN TEMPLATE: ad_showthread_firstpost_sig --><!-- END TEMPLATE: ad_showthread_firstpost_sig -->