Worksheet_Change doesn't sum

Nelson78

Well-known Member
Joined
Sep 11, 2017
Messages
525
Office Version
  1. 2007
Hello everybody.

In sheet 1 I have the below code ( Private Sub Worksheet_Change(ByVal Target As Range) )

At a certain point I have this instructions: the red one doesn't work (no errors, but the value is not updated).


Code:
'......
        
        Dim varResult As Variant
            varResult = Application.WorksheetFunction.SumIf( _
            Arg1:=Range(Cells(453, 2), Cells(524, 2)), _
            Arg2:="H", _
            Arg3:=Range(Cells(453, fc), Cells(524, fc)))
        
        
            [COLOR="#FF0000"]Cells(526, fc).Value = varResult[/COLOR]
            
'......

The strange aspect is the following: inserting a stop and going on with F8, the instruction in red works.

Any idea?


Code:
'......
        
        Dim varResult As Variant
            varResult = Application.WorksheetFunction.SumIf( _
            Arg1:=Range(Cells(453, 2), Cells(524, 2)), _
            Arg2:="H", _
            Arg3:=Range(Cells(453, fc), Cells(524, fc)))
        
                     [B][COLOR="#FF0000"]stop[/COLOR][/B]
        
            [COLOR="#FF0000"]Cells(526, fc).Value = varResult[/COLOR]
            
'......
 
Last edited:

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Hello everybody.

In sheet 1 I have the below code ( Private Sub Worksheet_Change(ByVal Target As Range) )

At a certain point I have this instructions: the red one doesn't work (no errors, but the value is not updated).


Code:
'......
        
        Dim varResult As Variant
            varResult = Application.WorksheetFunction.SumIf( _
            Arg1:=Range(Cells(453, 2), Cells(524, 2)), _
            Arg2:="H", _
            Arg3:=Range(Cells(453, fc), Cells(524, fc)))
        
        
            [COLOR="#FF0000"]Cells(526, fc).Value = varResult[/COLOR]
            
'......

The strange aspect is the following: inserting a stop and going on with F8, the instruction in red works.

Any idea?


Code:
'......
        
        Dim varResult As Variant
            varResult = Application.WorksheetFunction.SumIf( _
            Arg1:=Range(Cells(453, 2), Cells(524, 2)), _
            Arg2:="H", _
            Arg3:=Range(Cells(453, fc), Cells(524, fc)))
        
                     [B][COLOR="#FF0000"]stop[/COLOR][/B]
        
            [COLOR="#FF0000"]Cells(526, fc).Value = varResult[/COLOR]
            
'......

Could it be something about the following instructions?
Code:
Application.EnableEvents = False

Code:
Application.EnableEvents = True
 
Upvote 0

Forum statistics

Threads
1,213,561
Messages
6,114,315
Members
448,564
Latest member
ED38

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