Can Excel tell me how many rows are populated via a functions?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello All,

I wrote an application that takes a data set and uploads it to an Oracle
database. I'm cheating a little right now by using a hard coded number of
rows to parse and upload from a spread sheet to the database.

I'm wondering if there is a function that I can use in the VBA code that
will give me the number of rows that are populated so I can have my parser
run dynamically versus having to use the hard coded number of rows.

Many thanks,

Josh
 
Josh,

ActiveSheet.UsedRange.Rows.Count

will return the number of rows used on the worksheet.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Josh

To select the used range......

Sub select_range()
Dim someCells As Range
With ActiveSheet.UsedRange
Range("A1").Select
Set someCells = ActiveSheet.Range(ActiveCell, _
.Cells(.Cells.Count))
End With
someCells.Select
End Sub

To return the last row number...........

Sub FindLastRow()
Dim LastRow As Long
If WorksheetFunction.CountA(Cells) > 0 Then
'Search for any entry, by searching backwards by Rows.
LastRow = Cells.Find(What:="*", After:=[A1], _
SearchOrder:=xlByRows, _
searchdirection:=xlPrevious).Row
MsgBox LastRow
End If
End Sub


Gord Dibben Excel MVP
 

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