PC Review


Reply
Thread Tools Rate Thread

Correcting "Circular Action" in Worksheet_Change

 
 
Brian
Guest
Posts: n/a
 
      30th Jul 2009
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 With Quote
 
 
 
 
Jim Thomlinson
Guest
Posts: n/a
 
      30th Jul 2009
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 With Quote
 
Brian
Guest
Posts: n/a
 
      30th Jul 2009
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stop Word 2007 "correcting" "2009" to "2009-08-11"? John-J-B Microsoft Word Document Management 1 11th Aug 2009 10:35 AM
"CELL("FILENAME") NOT UPDATE AFTER "SAVE AS" ACTION yossie6 Microsoft Excel Misc 1 16th Jun 2008 12:16 PM
Why does FP insert 'action="_derived/nortbots.htm" webbot-action=" =?Utf-8?B?aGF2YXN1?= Microsoft Frontpage 2 12th Mar 2007 02:50 AM
<FORM METHOD="post" onSubmit="return fieldcheck()" name="orientation" action="http://ws-kitty.BU.edu/AT/survey/orientation/script/write.asp" language="JavaScript"> Joeyej Microsoft ASP .NET 0 4th Jun 2004 08:55 PM
Worksheet_Change Event "Circular Reference" Vyyk Drago Microsoft Excel Programming 2 19th Jul 2003 03:31 PM


Features
 

Advertising
 

Newsgroups
 


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