Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default Problem with action on range change

Greetings:

Im having difficulty getting a program to execute on a cell change (F31).

Cell F31 is actually a 1R x 5C range of cells (F31-J31 merged) with a
validation list. There are three possibilities in the list. The text for
each possibility is long, but for simplicity, assume that I need all five
cells and the values in the list are X, Y and Z. When the user selects a
value from the list in F31, cells F59 and F67 should change.

If the user chooses X in F31, I want F59 to show Yes and F67 to show No.
If the user chooses Y in F31, I want F59 to show No and F67 to show Yes.
If the user chooses Z in F31, I want F59 to show Yes and F67 to show Yes.
If the user deletes the entry in F31, I want both F59 and F67 to go blank.

The first three Ifs above work fine. However, when I delete an entry in
F31, F59 and F67 do not change.

Here is the relevant part of the code:

If Target.Address = "$F$31" Then
If MM.Range("F31") = "X" Then
MM.Cells(59, 6) = "Yes"
MM.Cells(67, 6) = "No"
ElseIf MM.Range("F31") = "Y" Then
MM.Cells(59, 6) = "No"
MM.Cells(67, 6) = "Yes"
ElseIf MM.Range("F31") = "Z" Then
MM.Cells(59, 6) = "Yes"
MM.Cells(67, 6) = "Yes"
Else
MM.Cells(59, 6) = ""
MM.Cells(67, 6) = ""
End If
End If

I notice that it DOES work if I unmerge the cells (and use ONLY F31 for
real), but I really do need the five-cell range.

Any ideas as to how I can get this to work? Help is appreciated.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Problem with action on range change

Maybe...

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.MergeArea.Cells(1).Address = "$F$31" Then
If Me.Range("F31") = "X" Then
Me.Cells(59, 6) = "Yes"
Me.Cells(67, 6) = "No"
ElseIf Me.Range("F31") = "Y" Then
Me.Cells(59, 6) = "No"
Me.Cells(67, 6) = "Yes"
ElseIf Me.Range("F31") = "Z" Then
Me.Cells(59, 6) = "Yes"
Me.Cells(67, 6) = "Yes"
Else
Me.Cells(59, 6) = ""
Me.Cells(67, 6) = ""
End If
End If
End Sub

=======
If you're sharing the workbook with people using xl97, you may want to read
Debra Dalgleish's notes:
http://contextures.com/xlDataVal08.html#Change



Marty wrote:

Greetings:

Im having difficulty getting a program to execute on a cell change (F31).

Cell F31 is actually a 1R x 5C range of cells (F31-J31 merged) with a
validation list. There are three possibilities in the list. The text for
each possibility is long, but for simplicity, assume that I need all five
cells and the values in the list are X, Y and Z. When the user selects a
value from the list in F31, cells F59 and F67 should change.

If the user chooses X in F31, I want F59 to show Yes and F67 to show No.
If the user chooses Y in F31, I want F59 to show No and F67 to show Yes.
If the user chooses Z in F31, I want F59 to show Yes and F67 to show Yes.
If the user deletes the entry in F31, I want both F59 and F67 to go blank.

The first three Ifs above work fine. However, when I delete an entry in
F31, F59 and F67 do not change.

Here is the relevant part of the code:

If Target.Address = "$F$31" Then
If MM.Range("F31") = "X" Then
MM.Cells(59, 6) = "Yes"
MM.Cells(67, 6) = "No"
ElseIf MM.Range("F31") = "Y" Then
MM.Cells(59, 6) = "No"
MM.Cells(67, 6) = "Yes"
ElseIf MM.Range("F31") = "Z" Then
MM.Cells(59, 6) = "Yes"
MM.Cells(67, 6) = "Yes"
Else
MM.Cells(59, 6) = ""
MM.Cells(67, 6) = ""
End If
End If

I notice that it DOES work if I unmerge the cells (and use ONLY F31 for
real), but I really do need the five-cell range.

Any ideas as to how I can get this to work? Help is appreciated.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default Problem with action on range change

Thanks for the response, Dave. Nobody will be using this with xl97, but
thanks for the tip.

Basically, you changed my: If Target.Address = "$F$31" Then

to: If Target.MergeArea.Cells(1).Address = "$F$31" Then.

As before, that works when I make a text selection in F31, but now when I
delete it gives me an "Application-defined or object-defined" error.

Any other ideas?



"Dave Peterson" wrote:

Maybe...

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.MergeArea.Cells(1).Address = "$F$31" Then
If Me.Range("F31") = "X" Then
Me.Cells(59, 6) = "Yes"
Me.Cells(67, 6) = "No"
ElseIf Me.Range("F31") = "Y" Then
Me.Cells(59, 6) = "No"
Me.Cells(67, 6) = "Yes"
ElseIf Me.Range("F31") = "Z" Then
Me.Cells(59, 6) = "Yes"
Me.Cells(67, 6) = "Yes"
Else
Me.Cells(59, 6) = ""
Me.Cells(67, 6) = ""
End If
End If
End Sub

=======
If you're sharing the workbook with people using xl97, you may want to read
Debra Dalgleish's notes:
http://contextures.com/xlDataVal08.html#Change



Marty wrote:

Greetings:

Iâm having difficulty getting a program to execute on a cell change (F31).

Cell F31 is actually a 1R x 5C range of cells (F31-J31 merged) with a
validation list. There are three possibilities in the list. The text for
each possibility is long, but for simplicity, assume that I need all five
cells and the values in the list are X, Y and Z. When the user selects a
value from the list in F31, cells F59 and F67 should change.

If the user chooses X in F31, I want F59 to show âœYes❠and F67 to show âœNoâ.
If the user chooses Y in F31, I want F59 to show âœNo❠and F67 to show âœYesâ.
If the user chooses Z in F31, I want F59 to show âœYes❠and F67 to show âœYesâ.
If the user deletes the entry in F31, I want both F59 and F67 to go blank.

The first three âœIfs❠above work fine. However, when I delete an entry in
F31, F59 and F67 do not change.

Here is the relevant part of the code:

If Target.Address = "$F$31" Then
If MM.Range("F31") = "X" Then
MM.Cells(59, 6) = "Yes"
MM.Cells(67, 6) = "No"
ElseIf MM.Range("F31") = "Y" Then
MM.Cells(59, 6) = "No"
MM.Cells(67, 6) = "Yes"
ElseIf MM.Range("F31") = "Z" Then
MM.Cells(59, 6) = "Yes"
MM.Cells(67, 6) = "Yes"
Else
MM.Cells(59, 6) = ""
MM.Cells(67, 6) = ""
End If
End If

I notice that it DOES work if I unmerge the cells (and use ONLY F31 for
real), but I really do need the five-cell range.

Any ideas as to how I can get this to work? Help is appreciated.


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Problem with action on range change

Poor testing on my part--I only checked X, Y, Z.

How about:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells(1).Address = "$F$31" Then
Application.EnableEvents = False
If Me.Range("F31") = "X" Then
Me.Cells(59, 6) = "Yes"
Me.Cells(67, 6) = "No"
ElseIf Me.Range("F31") = "Y" Then
Me.Cells(59, 6) = "No"
Me.Cells(67, 6) = "Yes"
ElseIf Me.Range("F31") = "Z" Then
Me.Cells(59, 6) = "Yes"
Me.Cells(67, 6) = "Yes"
Else
Me.Cells(59, 6) = ""
Me.Cells(67, 6) = ""
End If
Application.EnableEvents = True
End If
End Sub

But I think I'd use:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
With Target.Cells(1)
If .Address = "$F$31" Then
Application.EnableEvents = False
If .Value = "X" Then
Me.Cells(59, 6).Value = "Yes"
Me.Cells(67, 6).Value = "No"
ElseIf .Value = "Y" Then
Me.Cells(59, 6).Value = "No"
Me.Cells(67, 6).Value = "Yes"
ElseIf .Value = "Z" Then
Me.Cells(59, 6).Value = "Yes"
Me.Cells(67, 6).Value = "Yes"
Else
Me.Cells(59, 6).Value = ""
Me.Cells(67, 6).Value = ""
End If
Application.EnableEvents = True
End If
End With
End Sub




Marty wrote:

Thanks for the response, Dave. Nobody will be using this with xl97, but
thanks for the tip.

Basically, you changed my: If Target.Address = "$F$31" Then

to: If Target.MergeArea.Cells(1).Address = "$F$31" Then.

As before, that works when I make a text selection in F31, but now when I
delete it gives me an "Application-defined or object-defined" error.

Any other ideas?

"Dave Peterson" wrote:

Maybe...

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.MergeArea.Cells(1).Address = "$F$31" Then
If Me.Range("F31") = "X" Then
Me.Cells(59, 6) = "Yes"
Me.Cells(67, 6) = "No"
ElseIf Me.Range("F31") = "Y" Then
Me.Cells(59, 6) = "No"
Me.Cells(67, 6) = "Yes"
ElseIf Me.Range("F31") = "Z" Then
Me.Cells(59, 6) = "Yes"
Me.Cells(67, 6) = "Yes"
Else
Me.Cells(59, 6) = ""
Me.Cells(67, 6) = ""
End If
End If
End Sub

=======
If you're sharing the workbook with people using xl97, you may want to read
Debra Dalgleish's notes:
http://contextures.com/xlDataVal08.html#Change



Marty wrote:

Greetings:

Iâm having difficulty getting a program to execute on a cell change (F31).

Cell F31 is actually a 1R x 5C range of cells (F31-J31 merged) with a
validation list. There are three possibilities in the list. The text for
each possibility is long, but for simplicity, assume that I need all five
cells and the values in the list are X, Y and Z. When the user selects a
value from the list in F31, cells F59 and F67 should change.

If the user chooses X in F31, I want F59 to show âœYes❠and F67 to show âœNoâ.
If the user chooses Y in F31, I want F59 to show âœNo❠and F67 to show âœYesâ.
If the user chooses Z in F31, I want F59 to show âœYes❠and F67 to show âœYesâ.
If the user deletes the entry in F31, I want both F59 and F67 to go blank.

The first three âœIfs❠above work fine. However, when I delete an entry in
F31, F59 and F67 do not change.

Here is the relevant part of the code:

If Target.Address = "$F$31" Then
If MM.Range("F31") = "X" Then
MM.Cells(59, 6) = "Yes"
MM.Cells(67, 6) = "No"
ElseIf MM.Range("F31") = "Y" Then
MM.Cells(59, 6) = "No"
MM.Cells(67, 6) = "Yes"
ElseIf MM.Range("F31") = "Z" Then
MM.Cells(59, 6) = "Yes"
MM.Cells(67, 6) = "Yes"
Else
MM.Cells(59, 6) = ""
MM.Cells(67, 6) = ""
End If
End If

I notice that it DOES work if I unmerge the cells (and use ONLY F31 for
real), but I really do need the five-cell range.

Any ideas as to how I can get this to work? Help is appreciated.


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default Problem with action on range change

Excellent! Thanks very much.

"Dave Peterson" wrote:

Poor testing on my part--I only checked X, Y, Z.

How about:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells(1).Address = "$F$31" Then
Application.EnableEvents = False
If Me.Range("F31") = "X" Then
Me.Cells(59, 6) = "Yes"
Me.Cells(67, 6) = "No"
ElseIf Me.Range("F31") = "Y" Then
Me.Cells(59, 6) = "No"
Me.Cells(67, 6) = "Yes"
ElseIf Me.Range("F31") = "Z" Then
Me.Cells(59, 6) = "Yes"
Me.Cells(67, 6) = "Yes"
Else
Me.Cells(59, 6) = ""
Me.Cells(67, 6) = ""
End If
Application.EnableEvents = True
End If
End Sub

But I think I'd use:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
With Target.Cells(1)
If .Address = "$F$31" Then
Application.EnableEvents = False
If .Value = "X" Then
Me.Cells(59, 6).Value = "Yes"
Me.Cells(67, 6).Value = "No"
ElseIf .Value = "Y" Then
Me.Cells(59, 6).Value = "No"
Me.Cells(67, 6).Value = "Yes"
ElseIf .Value = "Z" Then
Me.Cells(59, 6).Value = "Yes"
Me.Cells(67, 6).Value = "Yes"
Else
Me.Cells(59, 6).Value = ""
Me.Cells(67, 6).Value = ""
End If
Application.EnableEvents = True
End If
End With
End Sub




Marty wrote:

Thanks for the response, Dave. Nobody will be using this with xl97, but
thanks for the tip.

Basically, you changed my: If Target.Address = "$F$31" Then

to: If Target.MergeArea.Cells(1).Address = "$F$31" Then.

As before, that works when I make a text selection in F31, but now when I
delete it gives me an "Application-defined or object-defined" error.

Any other ideas?

"Dave Peterson" wrote:

Maybe...

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.MergeArea.Cells(1).Address = "$F$31" Then
If Me.Range("F31") = "X" Then
Me.Cells(59, 6) = "Yes"
Me.Cells(67, 6) = "No"
ElseIf Me.Range("F31") = "Y" Then
Me.Cells(59, 6) = "No"
Me.Cells(67, 6) = "Yes"
ElseIf Me.Range("F31") = "Z" Then
Me.Cells(59, 6) = "Yes"
Me.Cells(67, 6) = "Yes"
Else
Me.Cells(59, 6) = ""
Me.Cells(67, 6) = ""
End If
End If
End Sub

=======
If you're sharing the workbook with people using xl97, you may want to read
Debra Dalgleish's notes:
http://contextures.com/xlDataVal08.html#Change



Marty wrote:

Greetings:

Iââ¬â¢m having difficulty getting a program to execute on a cell change (F31).

Cell F31 is actually a 1R x 5C range of cells (F31-J31 merged) with a
validation list. There are three possibilities in the list. The text for
each possibility is long, but for simplicity, assume that I need all five
cells and the values in the list are X, Y and Z. When the user selects a
value from the list in F31, cells F59 and F67 should change.

If the user chooses X in F31, I want F59 to show ââ¬ÅYesââ¬Â and F67 to show ââ¬ÅNoââ¬Â.
If the user chooses Y in F31, I want F59 to show ââ¬ÅNoââ¬Â and F67 to show ââ¬ÅYesââ¬Â.
If the user chooses Z in F31, I want F59 to show ââ¬ÅYesââ¬Â and F67 to show ââ¬ÅYesââ¬Â.
If the user deletes the entry in F31, I want both F59 and F67 to go blank.

The first three ââ¬ÅIfsââ¬Â above work fine. However, when I delete an entry in
F31, F59 and F67 do not change.

Here is the relevant part of the code:

If Target.Address = "$F$31" Then
If MM.Range("F31") = "X" Then
MM.Cells(59, 6) = "Yes"
MM.Cells(67, 6) = "No"
ElseIf MM.Range("F31") = "Y" Then
MM.Cells(59, 6) = "No"
MM.Cells(67, 6) = "Yes"
ElseIf MM.Range("F31") = "Z" Then
MM.Cells(59, 6) = "Yes"
MM.Cells(67, 6) = "Yes"
Else
MM.Cells(59, 6) = ""
MM.Cells(67, 6) = ""
End If
End If

I notice that it DOES work if I unmerge the cells (and use ONLY F31 for
real), but I really do need the five-cell range.

Any ideas as to how I can get this to work? Help is appreciated.

--

Dave Peterson


--

Dave Peterson

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
Change to a Cell causes action Jordan Excel Programming 3 April 6th 06 05:15 PM
Change in action when converting to *.xla Udo Excel Programming 1 March 10th 06 10:26 AM
Cell change causes action [email protected] Excel Programming 5 March 8th 06 02:22 PM
Evaluate cells for change and then action tim Excel Programming 0 February 18th 05 08:43 AM
Automating a date field to change on certain action TODD Excel Programming 3 November 7th 03 05:04 PM


All times are GMT +1. The time now is 11:32 PM.

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"