Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to know the number of (not empty) rows ?
Message
 
À
17/07/2003 12:57:14
Information générale
Forum:
Microsoft Office
Catégorie:
Excel
Divers
Thread ID:
00811154
Message ID:
00811217
Vues:
14
>Using VBA...

You would have to write some sort of routine that looped through the rows looking to see if it was empty. If you know that a non empty row has something in a certain column then that's real easy.

First get the last row of data
This logic assumes that you know that if there is data in any column, then there is also data in column 1.
'First go to the last row, but the first column
Range(Cells(65536, 1), Cells(65536, 1)).Select
'Then jump up to the last entry
Selection.End(xlUp).Select
MaxRow = ActiveCell.Row

DataCount = 0
'Then loop throguh them all
For Ctr = 1 to MaxRow
    Range(Cells(Ctr, 1), Cells(Ctr, 1)).Select
    If ActiveCell.Value <> "" Then DataCount = DataCount + 1
Next Ctr
If you don't know that a certain column has data then there is a way to check the entire row by adding another check. After you check column 1, also check the rest of the columns in that row. You can use logic like this
Range(Cells(Ctr, 1), Cells(Ctr, 1)).Select
'Go to the next entry in the row or the very end
Selection.End(xlToRight).Select
If ActiveCell.Column = {I forget but whatever the last col num is} Then
   'Cells in column 2 to the end of the row are blank
Endif
Hope it helps
___________________________
Kenneth Wonderley
http://www.wonderley.com


...the fruit of the Spirit is love, joy, peace, patience, kindness, goodness, faithfulness, gentleness and self-control.
Galatians 5:22 & 23
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform