Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Determing last (used) row in a sheet

Hi,

determing the last (used) row with

Set LastCell = ActiveSheet.Cells.SpecialCells(xlLastCell)
No_Rows = LastCell.Row

seems not to work, as soon I am also deleting some content of the sheet.

Does anybody know what the problem is (or what would be a better solution)?

Kind regards, AXEL
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Determing last (used) row in a sheet

With code - this has to be one of the most asked and answered queries!!

If you have a list set-up for your data one usually just looks for the last cell with data from the first column - usually A:A. This sets the first empty cell below all data in A column.

Set SRng = Activesheet.Cells(rows.count,1).end(xlup)(2)

If you don't have a list or know where the data might be, or need to know where the first whole blank row is below all data: then..

Dim i As Long, SRng As Range, Rcount As Long
Set SRng = ActiveSheet.UsedRange
Rcount = SRng.Rows.Count
For i = Rcount + SRng.Row To 1 Step -1
If Application.CountA(SRng.Rows(i)) < 0 Then Exit For
Next i
MsgBox "First empty row is " & SRng.Rows(i + 1).Address(0, 0)

.... is all you need :)

Columns can be reduced in a similar way.


Regards
Robert McCurdy

"Axel" wrote in message ...
Hi,

determing the last (used) row with

Set LastCell = ActiveSheet.Cells.SpecialCells(xlLastCell)
No_Rows = LastCell.Row

seems not to work, as soon I am also deleting some content of the sheet.

Does anybody know what the problem is (or what would be a better solution)?

Kind regards, AXEL
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default Determing last (used) row in a sheet

Try this:
No_Rows = Cells.Find(What:="*", _
After:=Range("A1"), _
LookAt:=xlPart, _
LookIn:=xlValues, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
Regards,
Stefi


€žAxel€ť ezt Ă*rta:

Hi,

determing the last (used) row with

Set LastCell = ActiveSheet.Cells.SpecialCells(xlLastCell)
No_Rows = LastCell.Row

seems not to work, as soon I am also deleting some content of the sheet.

Does anybody know what the problem is (or what would be a better solution)?

Kind regards, AXEL

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Determing n=? using COUNT CatPEG Excel Discussion (Misc queries) 2 January 6th 08 06:04 PM
Determing Range Criteria Jim Aksel Excel Worksheet Functions 11 September 18th 07 09:34 PM
Determing Value From Date IanEmery Excel Discussion (Misc queries) 7 July 18th 06 11:57 AM
Determing Last Row gti_jobert[_69_] Excel Programming 2 March 21st 06 02:35 PM
Determing first row in VBA when subtotaling Michael from Austin Excel Programming 1 March 17th 05 05:53 PM


All times are GMT +1. The time now is 06:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"