Private Sub Worksheet_Change(ByVal Target As Range)

Suzannah Robertson

New Member
Joined
Jan 13, 2010
Messages
23
Hello,

I'm trying to use a Private Sub Worksheet_Change(ByVal Target As Range) macro on one of my sheets and it's not working.
I've put in the code:

Private Sub Worksheet_Change(ByVal Target As Range)
'Partner
If Target.Row = 8 Then
thiscolumn = Target.Column

Range("e71").select...

and it's not triggered when I change information on row 8 of the worksheet... Can anyone see what I'm doing wrong?

Any help much appreciated.

thanks,
Suzannah
 
Glad you worked it out, Suzannah!

You can use this testing code for debugging:
Rich (BB code):

Private Sub Worksheet_Change(ByVal Target As Range)
  ' Code lines with MsgBox and Activate in it are for debugging only
  ' comment/delete such lines after debugging
  MsgBox "Worksheet_Change starts"
  Dim x As Range
  With Sheets("utilisation")
    .Activate
    For Each x In .Range("E71:E1000")
      If UCase(x.Value) = "E" Then Exit For
      If x <> 0 And x.HasFormula Then
        x.Activate
        MsgBox "GoalSeek for " & x.Address(0, 0) & vbLf & "ChangingCell " & x.Offset(-19, 52).Address(0, 0)
        x.GoalSeek Goal:=0, ChangingCell:=x.Offset(-19, 52)
        MsgBox IIf(x = 0, "Goal is achieved", "Unsuccessful")
      End If
    Next
  End With
  MsgBox "Worksheet_Change ends"    '  <-- for debugging only
End Sub

And this is for working.
It's the same as above but without debugging lines:
Rich (BB code):

Private Sub Worksheet_Change(ByVal Target As Range)
  Dim x As Range
  With Sheets("utilisation")
    For Each x In .Range("E71:E1000")
      If UCase(x.Value) = "E" Then Exit For
      If x <> 0 And x.HasFormula Then
        x.GoalSeek Goal:=0, ChangingCell:=x.Offset(-19, 52)
      End If
    Next
  End With
End Sub
Regards
 
Upvote 0

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,215,020
Messages
6,122,709
Members
449,093
Latest member
Mnur

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top