Hi
Wind: XP
Excel: 2k
I have two questions:
I have created a listbox in excel, which contains values from
Private Sub UserForm_Initialize()
ListBox1.ColumnCount = 4
ListBox1.RowSource = "b11:j17"
End Sub
from sheet1. While it loads all the data from rang("b11:j17"), I would like it to load only those line that have an ‘X” in ‘Open’, which is the 'C' column. The first question is how can I do this?
The values from the listbox come from sheet1 and the listbox looks exactly like the example bellow where ‘closed and ‘open’ are column and the rest are values in those:
A B C
closed open
one x
two x
three x
four x
five x
six x
Then, I want to user to select only one value from the listbox from the listbox and perform a task. However, when the user double click on the value, say the first one:
one x
the task that corresponds to that selection does not correspond to the line on sheet1. the only way I can make sure it does is by selecting the row before I open the listbox. Is there a way to fix this?
Here is the code:
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim newval As Date
If Sheet1.CommandButton1.Caption = "Start" Then
Sheet1.CommandButton1.Caption = "Stop Old"
Range("J2").Interior.ColorIndex = xlNone
'ActiveCell.Value = Time
Range("J2").Value = ""
Range("H2") = Now
Range("I" & CStr(ActiveCell.Row)).Activate
Call StartTimer
Call MyMainMacro
UserForm2.Hide
ElseIf Sheet1.CommandButton1.Caption = "Stop Old" Then
ActiveCell.Value = Time
If Range("J2").Cells.Interior.ColorIndex = 6 Then
Range("J" & CStr(ActiveCell.Row)).Cells.Interior.ColorIndex = 6
End If
Call StopTimer
Call StopIt
UserForm2.Hide
UserForm1.Show
Sheet1.CommandButton1.Caption = "Start"
End If
End Sub