so in my previous code, i left it at UserForm3. and i have the routine below to handle that. but since changing it to btn_Gen, now i get an "object error" because the routine checks for all loaded userforms. so how can i expose all the userforms named userform#.
QtyUF = miNoOfUserForms + 1
ufName = "UserForm" & QtyUF
and here is the function:
Function miNoOfUserForms() As Integer
Const iUSERFORM_TYPE As Integer = 3
Dim iNoOfUserForms As Integer
Dim objVBComponent As Object
iNoOfUserForms = 0
For Each objVBComponent In ThisWorkbook.VBProject.VBComponents
If objVBComponent.Type = iUSERFORM_TYPE Then
iNoOfUserForms = iNoOfUserForms + 1
miNoOfUserForms = iNoOfUserForms
so the function returns the number of total userforms when i need it to return the number of userforms named userform#
if you need to see the file, it is here on excelforum.