I've wrote a macro in an add-in that update the status-bar when you select a range:
This macro (included in "thisWorkbook
" of the add-in with a SheetSelectionChange)
write on status-bar the matrix sum product of the first and last column in selection.
It works very good but if there's a active filter I'd like it skip the hidden cells.
this is the code.
Private WithEvents App As Application
Private Sub App_SheetselectionChange(ByVal Sh As Object, ByVal Target As Range)
Dim vStatus As Variant
Dim nCols As Long
Dim prod_vett As Variant
On Error GoTo err_gest_
With Target
nCols = .Columns.Count
If nCols > 1 Then
prod_vett = Application.Evaluate("sum(" & .Columns(1).Address & "*" & .Columns(nCols).Address & ")")
vStatus = "Prodotto vettoriale: " & prod_vett
End If
End With
err_gest_:
If Err.Number <> 0 Then vStatus = False
Application.StatusBar = vStatus
End Sub
Private Sub Workbook_Open()
Application.StatusBar = False
Set App = Application 'Instantiate application level events
End Sub
If I use a cicle there is a problem: if a select all cells in worksheet the macro is too much long to give me a result. I try to use
With Target.SpecialCells(xlCellTypeVisible)
But it doesn't work. Have you got other solution?