by osknows » Thu Apr 15, 2010 11:08 pm
The worksheet change event fires when the worksheet changes and the cell/ranges that have changed are picked up in the 'Target' range object.
BA updates excel with 2 different refreshes, one for prices and one for balance updates etc
For price updates 16 columns are updated (cols A:P); therefore 'If Target.Columns.Count <> 16 Then Exit Sub' essentially checks if BA has refreshed prices rather than you just changing the odd cell. If BA has refreshed then Target.Columns.Count =16 and the code below runs otherwise it exits the VBA Subroutine
you can use either...
If Target.Columns.Count <> 16 Then Exit Sub
or
If Target.Columns.Count = 16 Then
'run code
End If