ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   code for showing userform on cell selection (https://www.excelbanter.com/excel-programming/285387-code-showing-userform-cell-selection.html)

M P Reddy

code for showing userform on cell selection
 
Hi
I want to have a userform show up on selection of specified cells (say A1,
C2 and D5) and the userform to disappear when the selection is moved to
other cells. Could someone please suggest a code for this?
Thanks in advance

M P Reddy
--





Greg Wilson[_4_]

code for showing userform on cell selection
 
Paste the following to the code module pertaining to the
worksheet involved:

Private Sub Worksheet_SelectionChange(ByVal Target As
Range)
Select Case Target.Address
Case "$A$1", "$C$2", "$D$5"
UserForm1.Show
Case Else
Unload UserForm1
End Select
End Sub

Regards,
Greg

-----Original Message-----
Hi
I want to have a userform show up on selection of

specified cells (say A1,
C2 and D5) and the userform to disappear when the

selection is moved to
other cells. Could someone please suggest a code for this?
Thanks in advance

M P Reddy
--




.


Bob Phillips[_6_]

code for showing userform on cell selection
 
A slight alternative.

Select the cells and give them a workbook name, such as FormCells. Then this
code in the worksheet code module as before

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Intersect(Target,Range("FormCells")) Is Nothing Then
Userform1.Show
End If

End Sub

This way you can add to your target cells without changing code by amending
the workbook name in Excel.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Greg Wilson" wrote in message
...
Paste the following to the code module pertaining to the
worksheet involved:

Private Sub Worksheet_SelectionChange(ByVal Target As
Range)
Select Case Target.Address
Case "$A$1", "$C$2", "$D$5"
UserForm1.Show
Case Else
Unload UserForm1
End Select
End Sub

Regards,
Greg

-----Original Message-----
Hi
I want to have a userform show up on selection of

specified cells (say A1,
C2 and D5) and the userform to disappear when the

selection is moved to
other cells. Could someone please suggest a code for this?
Thanks in advance

M P Reddy
--




.




M P Reddy

code for showing userform on cell selection
 
Thanks a lot Greg and Bob
M P Reddy
Bob Phillips wrote in message
...
A slight alternative.

Select the cells and give them a workbook name, such as FormCells. Then

this
code in the worksheet code module as before

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Intersect(Target,Range("FormCells")) Is Nothing Then
Userform1.Show
End If

End Sub

This way you can add to your target cells without changing code by

amending
the workbook name in Excel.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Greg Wilson" wrote in message
...
Paste the following to the code module pertaining to the
worksheet involved:

Private Sub Worksheet_SelectionChange(ByVal Target As
Range)
Select Case Target.Address
Case "$A$1", "$C$2", "$D$5"
UserForm1.Show
Case Else
Unload UserForm1
End Select
End Sub

Regards,
Greg

-----Original Message-----
Hi
I want to have a userform show up on selection of

specified cells (say A1,
C2 and D5) and the userform to disappear when the

selection is moved to
other cells. Could someone please suggest a code for this?
Thanks in advance

M P Reddy
--




.







All times are GMT +1. The time now is 03:41 PM.

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