List Box - Option If wrongly selected
Thanks Tom
That was very helpfull, with a little modification it's cool, basically
removed the exit sub & continued with the ElsIf function & removed the
UserForm business out. Now I can move on.
Can't say how much I appreciate this & the time scale was quick.
Thanks Rob
"Tom Ogilvy" wrote:
Sub ListBox1_Click()
Dim ans as Long
ans = MsgBox( "You Have Selected_" & ListBox1.Value & _
"_Do You Wish To Continue?", vbYesNo)
if ans = vbNo then
Listbox1.ListIndex = 0
exit sub
end if
UserForm1.Hide
Call UserForm1_Click
If ListBox1.Value = "400kV" Then
Call GIS_Voltage1_Sorter
ElseIf ListBox1.Value = "300kV" Then
Call GIS_Voltage1_Sorter
ElseIf ListBox1.Value = "230kV" Then
Call GIS_Voltage1_Sorter
ElseIf ListBox1.Value = "130kV" Then
Call GIS_Voltage_Sorter
ElseIf ListBox1.Value = "66kV" Then
Call GIS_Voltage_Sorter
ElseIf ListBox1.Value = "33kV" Then
Call S33kV_Sorter
ElseIf ListBox1.Value = "11kV" Then
Call S11kV_Sorter
ElseIf ListBox1.Value = "Ancillary" Then
Call Ancillary_Sorter
ElseIf ListBox1.Value = "Master" Then
Call Master_Sorter
End If
Call UserForm1_Click
End Sub
Might be a start.
--
Regards,
Tom Ogilvy
"Rob" wrote in message
...
In general what I am trying to achieve, is once an item has been selected,
a
message box appears for conformation which works, unfortunately if the
item
selected is incorrect, is to close the message box and restart from list
box,
this sorts of work though it remembers the list box original value which
is
is incorrect us aready stated. Also during second time round which is
activated by an Ok command button rather than just highlighting the value
which works first time round.
Attached is a copy of what was produced, would somebody explain where I
have
gone wrong please & wheter I should be using a loop system & wheter
stating
the list box values is applicable? Which is actually being read from a
seperate worksheet sheet, also I'd like the message box to only appear
once
during conformation.
Sub ListBox1_Click()
MsgBox "You Have Selected_" & ListBox1.Value & "_Do You Wish To
Continue?",
vbYesNo
UserForm1.Hide
If MsgBox("Continue?", vbYesNo) < vbYes Then
Call UserForm1_Click
ElseIf ListBox1.Value = "400kV" Then
Call GIS_Voltage1_Sorter
ElseIf ListBox1.Value = "300kV" Then
Call GIS_Voltage1_Sorter
ElseIf ListBox1.Value = "230kV" Then
Call GIS_Voltage1_Sorter
ElseIf ListBox1.Value = "130kV" Then
Call GIS_Voltage_Sorter
ElseIf ListBox1.Value = "66kV" Then
Call GIS_Voltage_Sorter
ElseIf ListBox1.Value = "33kV" Then
Call S33kV_Sorter
ElseIf ListBox1.Value = "11kV" Then
Call S11kV_Sorter
ElseIf ListBox1.Value = "Ancillary" Then
Call Ancillary_Sorter
ElseIf ListBox1.Value = "Master" Then
Call Master_Sorter
End If
Call UserForm1_Click
End Sub
|