Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Excel 2002, WinXP
I have a UF with a multi-selection ListBox, lbNMFee. I want to act on the instance wherein the user makes no selections in the ListBox. I have the following argument that is True if no selections are made. This code is in the beginning of the macro that is called by the OK button click. Is this correct? Thanks for your help. Otto If UFMgtFee.lbNMFee.ListIndex = -1 Then |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
"Otto Moehrbach" wrote in message
... Excel 2002, WinXP I have a UF with a multi-selection ListBox, lbNMFee. I want to act on the instance wherein the user makes no selections in the ListBox. I have the following argument that is True if no selections are made. This code is in the beginning of the macro that is called by the OK button click. Is this correct? Thanks for your help. Otto If UFMgtFee.lbNMFee.ListIndex = -1 Then Hi Otto, No, that won't work with a multi-select listbox. In this case you have to loop through each item in the list and check its Selected property. If all Selected properties return False then nothig is selected. Here's an example: Private Sub CommandButton1_Click() Dim bSelected As Boolean Dim lIndex As Long For lIndex = 0 To ListBox1.ListCount - 1 If ListBox1.Selected(lIndex) Then bSelected = True Next lIndex If Not bSelected Then MsgBox "Nothing selected." End Sub -- Rob Bovey, Excel MVP Application Professionals http://www.appspro.com/ * Take your Excel development skills to the next level. * Professional Excel Development http://www.appspro.com/Books/Books.htm |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Rob
Thanks for the help. You guys are invaluable. Otto "Rob Bovey" wrote in message ... "Otto Moehrbach" wrote in message ... Excel 2002, WinXP I have a UF with a multi-selection ListBox, lbNMFee. I want to act on the instance wherein the user makes no selections in the ListBox. I have the following argument that is True if no selections are made. This code is in the beginning of the macro that is called by the OK button click. Is this correct? Thanks for your help. Otto If UFMgtFee.lbNMFee.ListIndex = -1 Then Hi Otto, No, that won't work with a multi-select listbox. In this case you have to loop through each item in the list and check its Selected property. If all Selected properties return False then nothig is selected. Here's an example: Private Sub CommandButton1_Click() Dim bSelected As Boolean Dim lIndex As Long For lIndex = 0 To ListBox1.ListCount - 1 If ListBox1.Selected(lIndex) Then bSelected = True Next lIndex If Not bSelected Then MsgBox "Nothing selected." End Sub -- Rob Bovey, Excel MVP Application Professionals http://www.appspro.com/ * Take your Excel development skills to the next level. * Professional Excel Development http://www.appspro.com/Books/Books.htm |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Yes.
-- Regards, Tom Ogilvy "Otto Moehrbach" wrote in message ... Excel 2002, WinXP I have a UF with a multi-selection ListBox, lbNMFee. I want to act on the instance wherein the user makes no selections in the ListBox. I have the following argument that is True if no selections are made. This code is in the beginning of the macro that is called by the OK button click. Is this correct? Thanks for your help. Otto If UFMgtFee.lbNMFee.ListIndex = -1 Then |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Tom
Now I'm in a quandary. Bob says No and you say Yes. I tried the following code and I don't get the "Nothing" MsgBox when no selections are made. Help!! Otto If UFMgtFee.lbNMFee.ListIndex = -1 Then MsgBox = "Nothing" Unload UFMgtFee Else 'Do stuff with the selections End If "Tom Ogilvy" wrote in message ... Yes. -- Regards, Tom Ogilvy "Otto Moehrbach" wrote in message ... Excel 2002, WinXP I have a UF with a multi-selection ListBox, lbNMFee. I want to act on the instance wherein the user makes no selections in the ListBox. I have the following argument that is True if no selections are made. This code is in the beginning of the macro that is called by the OK button click. Is this correct? Thanks for your help. Otto If UFMgtFee.lbNMFee.ListIndex = -1 Then |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Otto,
Sorry for the confusion. Hopefully by now you read my other post that said I had missed the part about the multi-select setting. Go with Rob's solution. I thought it was peculiar that you were asking this question - guess that should have tipped me off that I was missing something. -- Regards, Tom Ogilvy "Otto Moehrbach" wrote in message ... Tom Now I'm in a quandary. Bob says No and you say Yes. I tried the following code and I don't get the "Nothing" MsgBox when no selections are made. Help!! Otto If UFMgtFee.lbNMFee.ListIndex = -1 Then MsgBox = "Nothing" Unload UFMgtFee Else 'Do stuff with the selections End If "Tom Ogilvy" wrote in message ... Yes. -- Regards, Tom Ogilvy "Otto Moehrbach" wrote in message ... Excel 2002, WinXP I have a UF with a multi-selection ListBox, lbNMFee. I want to act on the instance wherein the user makes no selections in the ListBox. I have the following argument that is True if no selections are made. This code is in the beginning of the macro that is called by the OK button click. Is this correct? Thanks for your help. Otto If UFMgtFee.lbNMFee.ListIndex = -1 Then |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sorry - missed the Multi-selection part - see Rob's answer.
for some reason I started reading on this line: I want to act on the instance wherein the user makes no selections in the ListBox. -- Regards, Tom Ogilvy "Tom Ogilvy" wrote in message ... Yes. -- Regards, Tom Ogilvy "Otto Moehrbach" wrote in message ... Excel 2002, WinXP I have a UF with a multi-selection ListBox, lbNMFee. I want to act on the instance wherein the user makes no selections in the ListBox. I have the following argument that is True if no selections are made. This code is in the beginning of the macro that is called by the OK button click. Is this correct? Thanks for your help. Otto If UFMgtFee.lbNMFee.ListIndex = -1 Then |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Tom
Thanks for that correction. I take it from what you said that your original response is correct for a 'MultiSelectSingle' ListBox. Is that correct? Otto "Tom Ogilvy" wrote in message ... Sorry - missed the Multi-selection part - see Rob's answer. for some reason I started reading on this line: I want to act on the instance wherein the user makes no selections in the ListBox. -- Regards, Tom Ogilvy "Tom Ogilvy" wrote in message ... Yes. -- Regards, Tom Ogilvy "Otto Moehrbach" wrote in message ... Excel 2002, WinXP I have a UF with a multi-selection ListBox, lbNMFee. I want to act on the instance wherein the user makes no selections in the ListBox. I have the following argument that is True if no selections are made. This code is in the beginning of the macro that is called by the OK button click. Is this correct? Thanks for your help. Otto If UFMgtFee.lbNMFee.ListIndex = -1 Then |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
for the multiselect property set to fmMultiSelectSingle - yes.
-- Regards, Tom Ogilvy "Otto Moehrbach" wrote in message ... Tom Thanks for that correction. I take it from what you said that your original response is correct for a 'MultiSelectSingle' ListBox. Is that correct? Otto "Tom Ogilvy" wrote in message ... Sorry - missed the Multi-selection part - see Rob's answer. for some reason I started reading on this line: I want to act on the instance wherein the user makes no selections in the ListBox. -- Regards, Tom Ogilvy "Tom Ogilvy" wrote in message ... Yes. -- Regards, Tom Ogilvy "Otto Moehrbach" wrote in message ... Excel 2002, WinXP I have a UF with a multi-selection ListBox, lbNMFee. I want to act on the instance wherein the user makes no selections in the ListBox. I have the following argument that is True if no selections are made. This code is in the beginning of the macro that is called by the OK button click. Is this correct? Thanks for your help. Otto If UFMgtFee.lbNMFee.ListIndex = -1 Then |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Tom. Otto
"Tom Ogilvy" wrote in message ... for the multiselect property set to fmMultiSelectSingle - yes. -- Regards, Tom Ogilvy "Otto Moehrbach" wrote in message ... Tom Thanks for that correction. I take it from what you said that your original response is correct for a 'MultiSelectSingle' ListBox. Is that correct? Otto "Tom Ogilvy" wrote in message ... Sorry - missed the Multi-selection part - see Rob's answer. for some reason I started reading on this line: I want to act on the instance wherein the user makes no selections in the ListBox. -- Regards, Tom Ogilvy "Tom Ogilvy" wrote in message ... Yes. -- Regards, Tom Ogilvy "Otto Moehrbach" wrote in message ... Excel 2002, WinXP I have a UF with a multi-selection ListBox, lbNMFee. I want to act on the instance wherein the user makes no selections in the ListBox. I have the following argument that is True if no selections are made. This code is in the beginning of the macro that is called by the OK button click. Is this correct? Thanks for your help. Otto If UFMgtFee.lbNMFee.ListIndex = -1 Then |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
error trapping | Excel Programming | |||
Trapping #NAME? question | Excel Programming | |||
trapping error | Excel Programming | |||
Error Trapping | Excel Programming | |||
Trapping the mouse | Excel Programming |