Either way is ok with me.
If you want it based on selecting a cell, you could use a worksheet event:
Rightclick on the worksheet tab that should have the behavior. Select view
code. Paste this in:
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Me.Range("a2:a99")) Is Nothing Then
Exit Sub
End If
UserForm1.Show
End Sub
You'll have to adjust the range and the userform name.
Or something like this to use an inputbox:
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim myStr As String
If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Me.Range("a2:a99")) Is Nothing Then
Exit Sub
End If
myStr = InputBox(Prompt:="what do you want to enter in " _
& Target.Address(0, 0) & "?")
If Trim(myStr) = "" Then
'do nothing
Else
Me.Unprotect Password:="hi"
Application.EnableEvents = False
Target.Value = myStr
Application.EnableEvents = True
Me.Protect Password:="hi"
End If
End Sub
> Dave,
>
[quoted text clipped - 25 lines]
> >
> > Dave Peterson

Signature
Dave Peterson
Mike Rogers - 16 Dec 2005 00:16 GMT
Dave
Wow thanks for the complete response!!!! I really do appreiciate it. I
think the simplest solution is the imput box. But I have a problem with
either way..... I already have a Private Sub Worksheet_SelectionChange(ByVal
Target As Range) procedure in place and, as little as I know, I know two of
them will not work well together. What changes would I need to make in the
input box code to call it from a command button, if that will work at all???
and then place the data in the active cell.
Thanks again
Mike Rogers
> Either way is ok with me.
>
[quoted text clipped - 72 lines]
> > >
> > > Dave Peterson
Dave Peterson - 16 Dec 2005 02:06 GMT
You'll have to combine them:
For instance:
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim myStr As String
If Target.Cells.Count > 1 Then Exit Sub
If Not (Intersect(Target, Me.Range("a2:a99")) Is Nothing) Then
myStr = InputBox(Prompt:="what do you want to enter in " _
& Target.Address(0, 0) & "?")
If Trim(myStr) = "" Then
'do nothing
Else
Me.Unprotect Password:="hi"
Application.EnableEvents = False
Target.Value = myStr
Application.EnableEvents = True
Me.Protect Password:="hi"
End If
End If
'your other code
End Sub
> Dave
>
[quoted text clipped - 89 lines]
> >
> > Dave Peterson

Signature
Dave Peterson
Mike Rogers - 16 Dec 2005 04:24 GMT
Dave,
Thanks for all the help!!!! Everything works perfect. I had a couple
different Worksheet_SelectionChange codes in some of the worksheets and
figured out how to combine them to work!!!!! Did not know that could be
done!!! Thanks for the help and the education.
Mike Rogers
> You'll have to combine them:
>
[quoted text clipped - 118 lines]
> > >
> > > Dave Peterson
Dave Peterson - 16 Dec 2005 17:07 GMT
It's nice when a plan comes together!
Glad you got it working.
> Dave,
>
[quoted text clipped - 131 lines]
> >
> > Dave Peterson

Signature
Dave Peterson