Dear All,
I turn to you, because i ran into some troubles. I want to get the value from certain cell and put it into listbox.
Here is the code i am using
I get permission denied when the for cycle starts. If i have the values of the cells in the same sheet everything works great.
I turn to you, because i ran into some troubles. I want to get the value from certain cell and put it into listbox.
Here is the code i am using
I get permission denied when the for cycle starts. If i have the values of the cells in the same sheet everything works great.
Code:
Private Sub CommandButton1_Click()
crit = Val(ComboBox2.Value)
If ActiveWorkbook.Worksheets("array_db").Cells(Rows.Count, 1).End(xlUp).Row = 1 Then
lr = 2
Else
lr = ActiveWorkbook.Worksheets("array_db").Cells(Rows.Count, 1).End(xlUp).Row
End If
'clear thebox
For x = 2 To lr
If ActiveWorkbook.Sheets("array_db").Cells(x, 1) = crit Then
'write it to the listbox
Me.ListBox1.AddItem ActiveWorkbook.Sheets(8).Cells(x, 1)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 1) = ActiveWorkbook.Worksheets("array_db").Cells(x, 2)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 2) = ActiveWorkbook.Worksheets("array_db").Cells(x, 3)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 3) = ActiveWorkbook.Worksheets("array_db").Cells(x, 4)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 4) = ActiveWorkbook.Worksheets("array_db").Cells(x, 5)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 5) = ActiveWorkbook.Worksheets("array_db").Cells(x, 6)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 6) = ActiveWorkbook.Worksheets("array_db").Cells(x, 7)
End If
Next x
End Sub