PDA

View Full Version : counting



oleg_v
01-18-2010, 01:06 PM
Hello

I need some help
i need to output in the messege box the amount of not empty cells in sheet2 column "B".

thanks Oleg

lucas
01-18-2010, 01:38 PM
Option Explicit
Sub GetData()
Dim i As Long
Dim cvalue As Long
'change the 1 to Cells to any number to start on a different row
For i = 1 To Sheets(2).Cells(Rows.Count, "B").End(xlUp).Row
If Sheets(2).Cells(i, "B").Value <> "" Then
cvalue = cvalue + 1
End If
Next i
MsgBox "There are " & cvalue & " values in Sheet 2 Column B"
End Sub

geekgirlau
01-18-2010, 05:46 PM
MsgBox WorksheetFunction.CountA(Range("Sheet2!B:B"))

lucas
01-18-2010, 07:15 PM
Slick geekgirlau

blaqk
01-19-2010, 09:20 PM
Thanks I was wondering about a similar problem. That was a nice answer.