![]() |
Is the array empty?
Excel 2002, WinXP
I display a UserForm with a Listbox (set to multi-select) and ask the user to select the names he wishes. I then use the procedure that John Walkenbach has in his book to build an array of the selected names. All works well if the user selects at least one name. There is a real possibility that the user will select no names, in which case the array will contain no names. I need to trap that situation. How can I trap the fact that no names were selected or that the array has no members? Thanks for your help. Otto |
Is the array empty?
Otto,
Perhaps: If Not IsEmpty(yourvarr(1)) Then which tests for an initial array value. Regards. "Otto Moehrbach" wrote in message ... Excel 2002, WinXP I display a UserForm with a Listbox (set to multi-select) and ask the user to select the names he wishes. I then use the procedure that John Walkenbach has in his book to build an array of the selected names. All works well if the user selects at least one name. There is a real possibility that the user will select no names, in which case the array will contain no names. I need to trap that situation. How can I trap the fact that no names were selected or that the array has no members? Thanks for your help. Otto --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.703 / Virus Database: 459 - Release Date: 10/06/2004 |
Is the array empty?
Sub test()
Dim arr() As String, bln As Boolean, i As Long ' ReDim arr(1) On Error Resume Next i = LBound(arr): bln = Not (Err.Number = 9) On Error GoTo 0 MsgBox bln End Sub -- Rob van Gelder - http://www.vangelder.co.nz/excel "Otto Moehrbach" wrote in message ... Excel 2002, WinXP I display a UserForm with a Listbox (set to multi-select) and ask the user to select the names he wishes. I then use the procedure that John Walkenbach has in his book to build an array of the selected names. All works well if the user selects at least one name. There is a real possibility that the user will select no names, in which case the array will contain no names. I need to trap that situation. How can I trap the fact that no names were selected or that the array has no members? Thanks for your help. Otto |
Is the array empty?
Stuart, Rob, Dave
Thanks for your help. That gave me what I needed. Dave, your suggestion was right on because I was counting anyway in the building of the array, so why didn't I think of that? Thanks again. Otto "Otto Moehrbach" wrote in message ... Excel 2002, WinXP I display a UserForm with a Listbox (set to multi-select) and ask the user to select the names he wishes. I then use the procedure that John Walkenbach has in his book to build an array of the selected names. All works well if the user selects at least one name. There is a real possibility that the user will select no names, in which case the array will contain no names. I need to trap that situation. How can I trap the fact that no names were selected or that the array has no members? Thanks for your help. Otto |
All times are GMT +1. The time now is 11:25 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com