Describe About Different Type Of Ranges With Last Row In Excel Sheet:-
Last Row For Any Column Or Row:-
Let us we define LastRow is as a integer and need to caculate the last row of perticulre column for range in sheet. Here is some syntax for last row with discription.
1. LastRow = ActiveSheet.UsedRange.Rows.Count
It give the value of used number of current sheet's row .
2. LastRow = Cells.Find("*",SearchOrder:=xlByRows,SearchDirection:=xlPrevious).Row
It also give the value of used number of current sheet's row with the search direction(From where is the used last row ) like a xlPrevious, xlAfter, xlNext.
3. LastRow = Range("A65536").End(xlUp).Row
It give directly the value of rows in specified column(Here is "A65536") .
4. LastRow = Cells.SpecialCells(xlCellTypeLastCell).Row
It simply calculate the last cell in column or row (Here we write row ).
5. LastRow = Sheet1.Coluumn(2).Find("*",,,,xlByRows,xlPrevious).Row
From this code we can find out last row with respect to column index and same as explain in 2 method written in above.
Range For Excel Sheet With Last Row:-
1. This syntax is for simply known range for user,here is "xlwbook" is name of
sheet and "rng" is excel range and A2 to B2 is
range.
rng=xlwbook.Range("A2","B2")
2.This syntax is for find out last row in perticulre column(here is "A") ,it
select whole rows of column A.
Workbooks().Sheets().Cells(Rows.Count, "A").End(xlUp).Row
3.If we want to find or calculate last row according to our need. We can Write the range as:-
rng=xlwbook.Range("A2","B2"& LastRow)
Here is " LastRow" is gives just number of rows in Column.
No comments:
Post a Comment