pjbur2005 via OfficeKB.com
Guest
Re: Using cell name to call userform
Hi Bob
thanks very much for your excellent reply, I just could not see the wood for
the trees, I made a small change to suit my direct needs but worked great.
if you see any potential problems with this let me know.
Public Sub cellnames()
Dim cellname As Name
On Error Resume Next
Set cellname = Selection.Name ' this rather than cells as range
If cellname Is Nothing Then
Exit Sub
Else
ShowUserFormByName cellname.Name & "form"
End If
End Sub
show userformbyname sub needed no change, may not end up using error trap as
i exit during cellnames if nothing but have left it just in case.
My sincere thanks for your reply
best wishes
Paul
Bob Phillips wrote:
>Public Sub cellnames()
>Dim cell As Range
> For Each cell In Selection
> If cell.Value <> "" Then
> ShowUserFormByName cell.Value & "form"
> End If
> Next cell
>End Sub
>
>Public Sub ShowUserFormByName(FormName As String)
>Dim oUserForm As Object
> On Error GoTo err
> Set oUserForm = UserForms.Add(FormName)
> oUserForm.Show
> Exit Sub
>err:
> Select Case err.Number
> Case 424:
> MsgBox "The Userform with the name " & FormName & _
> " was not found.", vbExclamation, "Load userforn by name"
> Case Else:
> MsgBox err.Number & ": " & err.Description, vbCritical, _
> "Load userforn by name"
> End Select
>End Sub
>
>--
>
>HTH
>
>Bob Phillips
>
>(remove nothere from the email address if mailing direct)
>
>> Hi there I have a worksheet form that has vba to manage it what i am stuck on
>> is i want to take the name of an active cell add the word "form" to it and
>[quoted text clipped - 47 lines]
>> Thanks
>> Paul
--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200602/1
Bookmarks