Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 683
Default Correcting "Circular Action" in Worksheet_Change

I'm having a problem with the a Worksheet_Change macro. I want the code to
take the value of a cell perform a goal seek then return that value to null.

Here is the code:

Sub Worksheet_Change(ByVal Target As Range)
Dim sGoal As String, iRow As Integer

If Target.Column = 10 And Target.Row 6 And Target.Row < 9 Then
sGoal = Target.Value
iRow = Target.Row
Select Case iRow
Case 7
Range("F36").GoalSeek Goal:=sGoal, ChangingCell:=Range("J3")
Case 8
Range("J6").GoalSeek Goal:=sGoal * 100, ChangingCell:=Range("J3")
End Select
'Range("J" & iRow).Value = ""
End If

End Sub

I'm assuming since it works fine as it is now, and it doesn't work when the
'Range line is activated, that when it goes to change the cell value back to
null, it recalls the Worksheet_Change Routine, then gives me an error on the
GoalSeek line. Any thoughts on how to do this?

Thanks in advance. And I'll be sure to check yes to answers.
--
Brian
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Correcting "Circular Action" in Worksheet_Change

Sub Worksheet_Change(ByVal Target As Range)
Dim sGoal As String, iRow As Integer

If Target.Column = 10 And Target.Row 6 And Target.Row < 9 Then
Application.enableevents = false 'New code****
sGoal = Target.Value
iRow = Target.Row
Select Case iRow
Case 7
Range("F36").GoalSeek Goal:=sGoal, ChangingCell:=Range("J3")
Case 8
Range("J6").GoalSeek Goal:=sGoal * 100, ChangingCell:=Range("J3")
End Select
'Range("J" & iRow).Value = ""
Application.enableevents = true 'New code****
End If


--
HTH...

Jim Thomlinson


"Brian" wrote:

I'm having a problem with the a Worksheet_Change macro. I want the code to
take the value of a cell perform a goal seek then return that value to null.

Here is the code:

Sub Worksheet_Change(ByVal Target As Range)
Dim sGoal As String, iRow As Integer

If Target.Column = 10 And Target.Row 6 And Target.Row < 9 Then
sGoal = Target.Value
iRow = Target.Row
Select Case iRow
Case 7
Range("F36").GoalSeek Goal:=sGoal, ChangingCell:=Range("J3")
Case 8
Range("J6").GoalSeek Goal:=sGoal * 100, ChangingCell:=Range("J3")
End Select
'Range("J" & iRow).Value = ""
End If

End Sub

I'm assuming since it works fine as it is now, and it doesn't work when the
'Range line is activated, that when it goes to change the cell value back to
null, it recalls the Worksheet_Change Routine, then gives me an error on the
GoalSeek line. Any thoughts on how to do this?

Thanks in advance. And I'll be sure to check yes to answers.
--
Brian

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 683
Default Correcting "Circular Action" in Worksheet_Change

Thanks Jim,

Works like a champ.
--
Brian


"Jim Thomlinson" wrote:

Sub Worksheet_Change(ByVal Target As Range)
Dim sGoal As String, iRow As Integer

If Target.Column = 10 And Target.Row 6 And Target.Row < 9 Then
Application.enableevents = false 'New code****
sGoal = Target.Value
iRow = Target.Row
Select Case iRow
Case 7
Range("F36").GoalSeek Goal:=sGoal, ChangingCell:=Range("J3")
Case 8
Range("J6").GoalSeek Goal:=sGoal * 100, ChangingCell:=Range("J3")
End Select
'Range("J" & iRow).Value = ""
Application.enableevents = true 'New code****
End If


--
HTH...

Jim Thomlinson


"Brian" wrote:

I'm having a problem with the a Worksheet_Change macro. I want the code to
take the value of a cell perform a goal seek then return that value to null.

Here is the code:

Sub Worksheet_Change(ByVal Target As Range)
Dim sGoal As String, iRow As Integer

If Target.Column = 10 And Target.Row 6 And Target.Row < 9 Then
sGoal = Target.Value
iRow = Target.Row
Select Case iRow
Case 7
Range("F36").GoalSeek Goal:=sGoal, ChangingCell:=Range("J3")
Case 8
Range("J6").GoalSeek Goal:=sGoal * 100, ChangingCell:=Range("J3")
End Select
'Range("J" & iRow).Value = ""
End If

End Sub

I'm assuming since it works fine as it is now, and it doesn't work when the
'Range line is activated, that when it goes to change the cell value back to
null, it recalls the Worksheet_Change Routine, then gives me an error on the
GoalSeek line. Any thoughts on how to do this?

Thanks in advance. And I'll be sure to check yes to answers.
--
Brian

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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
"CELL("FILENAME") NOT UPDATE AFTER "SAVE AS" ACTION yossie6 Excel Discussion (Misc queries) 1 June 16th 08 12:16 PM
"IF" with no "false" action - Using Text Danny@Kendal Excel Discussion (Misc queries) 0 December 9th 05 10:20 AM
"IF" with no "false" action - Using Text Rowan Drummond Excel Discussion (Misc queries) 0 December 9th 05 01:01 AM
Worksheet_Change Event "Circular Reference" Vyyk Drago Excel Programming 2 July 19th 03 03:31 PM


All times are GMT +1. The time now is 06:44 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"