View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_3_] Bob Phillips[_3_] is offline
external usenet poster
 
Posts: 2,420
Default rng.Count ====results wrong value?

MsgBox Application.Count(myRng)


--
__________________________________
HTH

Bob

"shiro" wrote in message
...
And then,
how to manipulate the msgbox so that it says
0 if actually no data in cell Q10 and Q11?


"Nayab" wrote in message
...
On Jun 19, 4:13 pm, "shiro" wrote:
Sub tEST()
Dim LastRow As Long
Dim myRng As Range
Dim WS As Worksheet

Set WS = Sheets("DATA 2") '<<< Ganti jika perlu
With WS
LastRow = .Cells(.Rows.Count, "Q").End(xlUp).Row
Set myRng = .Range("Q11:Q" & LastRow)

MsgBox myRng.Count
End With
End Sub
================================================
Hi all,
is there something wrong with the above code.?
Actually,there is no any data on the .Range("Q11:Q" & LastRow)
Why does the msgbox return the value 2
instead 0?.

rgds,

Shiro


Actually it is returning the value of the number of the selected cells
in myRng. So it is actually selecting Q10, Q11 and hence returns 2,
the count of selected cells