I'm new to vba and object programming and am trying to take a column and simply sum it to use it as a test for whether or not to take action. I found a sample code on the net, but am getting error 91....not sure what I'm doing wrong. Can someone help?
Thanks in advance...Pam
Public rngMyCol As Range
Sub CallIt()
ActiveSheet.Columns(4).Select 'selecting a column on the spreadsheet
'the following line errors (trying to set an object range to use in the next
function - which is the one I found on the net)
rngMyCol = Application.Cells.Columns
Worksheet_SelectionChange (rngMyCol) ' call the function with the set range
End Sub
' the following is the function that I "borrowed" from the net.....
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Dim myVar As Double
myVar = Application.Sum(Columns(Target.Column))
If myVar <> 0 Then
Application.StatusBar = Format(myVar, "###,###")
Else
Application.StatusBar = False
End If
End Sub