Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
removing drop down option after its been selected | Excel Worksheet Functions | |||
A validated List which link to selected cells according to what is selected on the list | Excel Worksheet Functions | |||
Option Button - multiple selected | Excel Worksheet Functions | |||
Having a macro recognize when an option button has been selected | Excel Programming | |||
Checking to see if user selected an Option | Excel Programming |