Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default On Exit Command

How do I set it a cell so that when a certain cell's
content has been changed other cells contents change.

For example I have 20 cells that either have a 'y'
or 'n'. These 'y', or 'n' values are input manually.

There is also one cell that contains a number that is
input manually.

I would like to set it so that the 20 cell's that contain
an 'y' or 'n' value are set to 'n' when the cell that has
a number in it is changed and only when it changes.

If this is not possible how about doing the same thing
when the cell is exited?

Thanks Ben


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default On Exit Command

Ben,

This worksheet event code will do it

Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False
On Error GoTo ws_exit
If Not Intersect(Target, Range("A1")) Is Nothing Then
Range("myRange").Value = "n"
End If

ws_exit:

Application.EnableEvents = True
End Sub

This goes in the worksheet cfode module. You also need to define a named
ranmge called 'myRange' to cover the cells you want to change


--

HTH

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

"Ben" wrote in message
...
How do I set it a cell so that when a certain cell's
content has been changed other cells contents change.

For example I have 20 cells that either have a 'y'
or 'n'. These 'y', or 'n' values are input manually.

There is also one cell that contains a number that is
input manually.

I would like to set it so that the 20 cell's that contain
an 'y' or 'n' value are set to 'n' when the cell that has
a number in it is changed and only when it changes.

If this is not possible how about doing the same thing
when the cell is exited?

Thanks Ben




  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default On Exit Command

Bob,

Thanks! How do I define the ranmge?

------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False
On Error GoTo ws_exit
If Not Intersect(Target, Range("D1")) Is Nothing Then
Range("D3:D26").Value = "n"
End If

ws_exit:

Application.EnableEvents = True
End Sub



-----Original Message-----
Ben,

This worksheet event code will do it

Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False
On Error GoTo ws_exit
If Not Intersect(Target, Range("A1")) Is Nothing Then
Range("myRange").Value = "n"
End If

ws_exit:

Application.EnableEvents = True
End Sub

This goes in the worksheet cfode module. You also need

to define a named
ranmge called 'myRange' to cover the cells you want to

change


--

HTH

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

"Ben" wrote in

message
...
How do I set it a cell so that when a certain cell's
content has been changed other cells contents change.

For example I have 20 cells that either have a 'y'
or 'n'. These 'y', or 'n' values are input manually.

There is also one cell that contains a number that is
input manually.

I would like to set it so that the 20 cell's that

contain
an 'y' or 'n' value are set to 'n' when the cell that

has
a number in it is changed and only when it changes.

If this is not possible how about doing the same thing
when the cell is exited?

Thanks Ben




.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default On Exit Command

Select all of the cells to be in the range
Type the name in the Names box (the little textbox above the spreadsheet,
below the toolbars, and to the left of the formula bar)

Or if all the cells are contiguous, you can specify the range just as you
have done in your example.

--

HTH

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

wrote in message
...
Bob,

Thanks! How do I define the ranmge?

------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False
On Error GoTo ws_exit
If Not Intersect(Target, Range("D1")) Is Nothing Then
Range("D3:D26").Value = "n"
End If

ws_exit:

Application.EnableEvents = True
End Sub



-----Original Message-----
Ben,

This worksheet event code will do it

Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False
On Error GoTo ws_exit
If Not Intersect(Target, Range("A1")) Is Nothing Then
Range("myRange").Value = "n"
End If

ws_exit:

Application.EnableEvents = True
End Sub

This goes in the worksheet cfode module. You also need

to define a named
ranmge called 'myRange' to cover the cells you want to

change


--

HTH

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

"Ben" wrote in

message
...
How do I set it a cell so that when a certain cell's
content has been changed other cells contents change.

For example I have 20 cells that either have a 'y'
or 'n'. These 'y', or 'n' values are input manually.

There is also one cell that contains a number that is
input manually.

I would like to set it so that the 20 cell's that

contain
an 'y' or 'n' value are set to 'n' when the cell that

has
a number in it is changed and only when it changes.

If this is not possible how about doing the same thing
when the cell is exited?

Thanks Ben




.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default On Exit Command

Bob,

Thank you that works Perfectly!!

Ben
-----Original Message-----
Select all of the cells to be in the range
Type the name in the Names box (the little textbox above

the spreadsheet,
below the toolbars, and to the left of the formula bar)

Or if all the cells are contiguous, you can specify the

range just as you
have done in your example.

--

HTH

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

wrote in message
...
Bob,

Thanks! How do I define the ranmge?

------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False
On Error GoTo ws_exit
If Not Intersect(Target, Range("D1")) Is Nothing

Then
Range("D3:D26").Value = "n"
End If

ws_exit:

Application.EnableEvents = True
End Sub



-----Original Message-----
Ben,

This worksheet event code will do it

Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False
On Error GoTo ws_exit
If Not Intersect(Target, Range("A1")) Is Nothing

Then
Range("myRange").Value = "n"
End If

ws_exit:

Application.EnableEvents = True
End Sub

This goes in the worksheet cfode module. You also need

to define a named
ranmge called 'myRange' to cover the cells you want to

change


--

HTH

Bob Phillips
... looking out across Poole Harbour to the

Purbecks
(remove nothere from the email address if mailing

direct)

"Ben" wrote in

message
...
How do I set it a cell so that when a certain cell's
content has been changed other cells contents

change.

For example I have 20 cells that either have a 'y'
or 'n'. These 'y', or 'n' values are input

manually.

There is also one cell that contains a number that

is
input manually.

I would like to set it so that the 20 cell's that

contain
an 'y' or 'n' value are set to 'n' when the cell

that
has
a number in it is changed and only when it changes.

If this is not possible how about doing the same

thing
when the cell is exited?

Thanks Ben




.



.



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
command code ( GOTO command) in formula calan New Users to Excel 1 June 11th 09 09:44 AM
Pivot Table Error Message - "Command Text not set for command obje Jeff Divian Excel Discussion (Misc queries) 0 November 7th 07 10:26 PM
Run when exit PH NEWS Excel Worksheet Functions 1 July 18th 06 03:53 PM
How do i create a command button or macro to exit Microsoft Excel raj Excel Worksheet Functions 1 April 30th 05 02:17 PM
Exit Sub? Eva Shanley[_2_] Excel Programming 3 December 24th 03 02:15 PM


All times are GMT +1. The time now is 08:45 PM.

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

About Us

"It's about Microsoft Excel"