nomber of lines

  • Thread starter Thread starter wasssu
  • Start date Start date
W

wasssu

I have a sheet in excel and i want to know how many lines are "used
(used line = there is cell(s) with something in it).
How can i do that in Macro-VBA ? What is the "simplies(rapid) way"?
don't want to use a for, while or somethig like that
 
wasssu

I normally do it this way (XL97 and up). It goes to the bottom of column A
and then up. This way it is not fooled if there is no data in some cells in
column A. You could of course use any column. It need to be the one you are
expecting the most data in. If this is variable, post back and we'll find
another solution

Sub findLastCell()
Dim lLastRow As Long
lLastRow = Range("A65536").End(xlUp).Row
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(e-mail address removed)
 
wasssu

Sub CountNonBlankCells()
Dim mycount As Integer
mycount = Application.CountA(Selection)
MsgBox "The number of non-blank cell(s) in this selection is : " _
& mycount, vbInformation, "Count Cells"
End Sub

Gord Dibben Excel MVP
 
GetBottomRow = TheSheet.Cells.Find(What:="*", SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row



LastColumn = TheSheet.Cells.Find(What:="*", SearchOrder:=xlByColumns
_
SearchDirection:=xlPrevious).Colum
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top