Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Activating VB form by changing cells

I need to know how I can show a UserForm or run other code by selecting or changing the value of a cell in Excel? Without using a VB object such as a command button that needs to be clicked.


A B C D E
i.e. - 1 | | 4 | | |
2 | | | | |
3 | | | | |

If the contents of cell C1 are changed to "6", a UserForm should appear.
The Sub Worksheet_SelectionChange() does not seem to work.
Need Help Please!!!!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Activating VB form by changing cells

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("C1")) Is Nothing Then
If Target.Value = 6 Then
Userform1.Show
End If
End If

ws_exit:
Application.EnableEvents = True
End Sub


--

HTH

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

"CTInt04" wrote in message
...
I need to know how I can show a UserForm or run other code by selecting or

changing the value of a cell in Excel? Without using a VB object such as a
command button that needs to be clicked.


A B C D E
i.e. - 1 | | 4 | | |
2 | | | | |
3 | | | | |

If the contents of cell C1 are changed to "6", a UserForm should appear.
The Sub Worksheet_SelectionChange() does not seem to work.
Need Help Please!!!!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Activating VB form by changing cells

This works too.. A little simpler..

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$1" And Target.Value = 6 Then
MsgBox "Tada" 'Open your form here...
End If
End Sub

"Bob Phillips" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("C1")) Is Nothing Then
If Target.Value = 6 Then
Userform1.Show
End If
End If

ws_exit:
Application.EnableEvents = True
End Sub


--

HTH

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

"CTInt04" wrote in message
...
I need to know how I can show a UserForm or run other code by selecting or

changing the value of a cell in Excel? Without using a VB object such as a
command button that needs to be clicked.


A B C D E
i.e. - 1 | | 4 | | |
2 | | | | |
3 | | | | |

If the contents of cell C1 are changed to "6", a UserForm should appear.
The Sub Worksheet_SelectionChange() does not seem to work.
Need Help Please!!!!




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Activating VB form by changing cells

It is only a little simpler because it has stripped all of the code I have
added to stop re-triggering the event and handle errors in an orderly
fashion. So shorter yes, better, no.

--

HTH

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

"Jim Thomlinson" <Jim wrote in message
...
This works too.. A little simpler..

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$1" And Target.Value = 6 Then
MsgBox "Tada" 'Open your form here...
End If
End Sub

"Bob Phillips" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("C1")) Is Nothing Then
If Target.Value = 6 Then
Userform1.Show
End If
End If

ws_exit:
Application.EnableEvents = True
End Sub


--

HTH

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

"CTInt04" wrote in message
...
I need to know how I can show a UserForm or run other code by

selecting or
changing the value of a cell in Excel? Without using a VB object such as

a
command button that needs to be clicked.


A B C D E
i.e. - 1 | | 4 | | |
2 | | | | |
3 | | | | |

If the contents of cell C1 are changed to "6", a UserForm should

appear.
The Sub Worksheet_SelectionChange() does not seem to work.
Need Help Please!!!!






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Activating cells with checkbox KeyAdministration Excel Worksheet Functions 1 May 30th 08 02:14 PM
Dynamically Activating Cells Rob Excel Discussion (Misc queries) 5 June 5th 07 04:39 PM
Activating a modeless form R Avery Excel Programming 2 February 4th 04 06:41 PM
Activating a worksheet with a user form open on the screen KimberlyC Excel Programming 4 August 29th 03 08:44 PM
Copy one spreadsheet into another without activating second spreadsheet's user form P Cheek Excel Programming 3 July 23rd 03 06:26 PM


All times are GMT +1. The time now is 07:12 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"