Not getting right Value in Textbox1.Text and Label1.Caption when clicking on Combobox1

NimishK

Well-known Member
Joined
Sep 4, 2015
Messages
688
Hi Anyone who could correct me for my error

Basically Not getting right Value in Textbox1.Text and Label1.Caption when clicking on Combobox1

In module
<code>
Code:
Option Explicit
Public arrayProdWs(1 To 2, 1 To 2, 1 To 2) As String
Public arrayAccWs(1 To 2, 1 To 2, 1 To 2) As String
Public arrayCoName(1 To 2, 1 To 2, 1 To 2) As String

Public prodWs As Integer, accWs As Integer, CoName As Integer
</code>

in UserForm
<code>
Code:
Private Sub UserForm_Initialize()

arrayProdWs(1, 1, 1) = "Product Sheet1"
arrayAccWs(1, 1, 1) = "Acc Sheet1"
arrayCoName(1, 1, 1) = "Co Name 1"


arrayProdWs(2, 1, 1) = "Product Sheet2"
arrayAccWs(2, 1, 1) = "Acc Sheet2"
arrayCoName(2, 1, 1) = "Co Name 2"

For prodWs% = 1 To UBound(arrayProdWs, 1)
    UserForm1.ComboBox1.AddItem arrayProdWs(prodWs%, 1, 1)
Next prodWs%

End Sub


Private Sub ComboBox1_Click()

[COLOR=#ff0000][B]'Clicking on Combobox not able to get value in Textbox of AccSheet 1 and AccSheet2
'in Label not able to get Co Name 1 and Co Name 2
[/B][/COLOR]

For prodWs% = 1 To UBound(arrayProdWs, 1)
      For accWs% = 1 To UBound(arrayAccWs, 1)
             UserForm1.TextBox1.Text = arrayAccWs(ComboBox1.ListIndex + 1, prodWs%, accWs%)
             UserForm1.Label1.Caption = arrayAccWs(1, 1, accWs%)
      Next accWs%
 Next prodWs%


End sub

</code>

Thanks
 
Last edited:

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Why are you looping through prodW and accW?

Also, why are you using a 3 dimensional array?
 
Upvote 0
In some different way i wanted to try. the reason is to shorten the coding for Worksheets rather then same coding for individual sheets
 
Upvote 0

Forum statistics

Threads
1,223,959
Messages
6,175,644
Members
452,663
Latest member
MEMEH

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