Hopefully, this will get you started. It yields the correct result, but doesn't automatically recalculate, even with the Application.Volatile statement. I tried using Application.Calculate in the SheetChange event, but hiding and unhiding columns did not make that event fire. I'm sure there's a way to force recalculation when you need it, though.
Application.Volatile True
If rg.Rows.count > 1 Then
Set rg = rg.Resize(1)
End If
On Error Resume Next
For i = 1 To rg.Columns.count
If Columns(i).Hidden Then
n = n + 1
End If
Next
ColNotVisible = n
HTH