View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Bob Flanagan Bob Flanagan is offline
external usenet poster
 
Posts: 340
Default How to know whether sheet1 contains any data in it?

if application.counta(cells) = 0 then
'no data
end if

You can't use UsedRange on an empty worksheet - an error will occur.

Robert Flanagan
Macro Systems
Delaware, U.S. 302-234-9857
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel

"kvenku " wrote in message
...
Hi,
I have a VBA application where i need to know that sheets1 contains
any data on it

I tried this and this take a long time to execute..Can you help me out


For StrRow = 1 To Rows.Count
For StrCol = 1 To Columns.Count
If Len(Cells(StrCol, StrRow).Value) 0 Then
MsgBox "Found"
Exit Sub
End If
Next
Next


---
Message posted from http://www.ExcelForum.com/