ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   add to a dynamic list (https://www.excelbanter.com/excel-programming/358876-add-dynamic-list.html)

L Scholes

add to a dynamic list
 
I have a ComboBox (txtSignature) on a userform that gets it's
information from a dynamic list (DealerName). If I enter a name that is

not in DealerName, I get an error message "Run-time error '381': Could
not get the List property. Invalid property array index." Instead of
this message, I would like to give the user a message allowing three
options:
1) add the new name to the dynamic list and enter the new name onto the

form as if the name were there all along;
2) add as if it were in the list, but don't add it to the list;
3) cancel and do nothing but clear the user form.
Using vbaMsgBoxYesNoCancel, I just don't know how to code it where
above option 1 = yes, 2 = no, 3 = cancel in the MsgBox
Does anybody have the code for this?
Thanks in advance


Crowbar via OfficeKB.com

add to a dynamic list
 
Do this to identify the error and then show a NEW userform to add your
desired controls

Above the line that gets the error message put this

On Error Goto ErrorHandler


Somewhere else in the script type

ErrorHandler:
If Err.Number = 381 then
userform.show ' Put you NEW userform name here
exit sub 'Keep this if you want to terminate the userfrom here
end if

With this you will then need to create a NEW userform to accomodate the
controls you require

Let us know how you get on and If you have any trouble you can email me at


--
Message posted via
http://www.officekb.com


All times are GMT +1. The time now is 11:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com