Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 718
Default List Box - Option If wrongly selected

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default List Box - Option If wrongly selected

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




  #3   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 718
Default 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





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
removing drop down option after its been selected bbennett2 Excel Worksheet Functions 4 December 10th 08 01:40 AM
A validated List which link to selected cells according to what is selected on the list WL Excel Worksheet Functions 1 June 5th 06 08:52 PM
Option Button - multiple selected alanap Excel Worksheet Functions 1 April 17th 06 11:04 PM
Having a macro recognize when an option button has been selected Linking to specific cells in pivot table Excel Programming 3 August 26th 05 05:21 PM
Checking to see if user selected an Option Kirk[_2_] Excel Programming 1 August 27th 03 09:46 PM


All times are GMT +1. The time now is 03:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"