Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Brooklyn Smith   on Nov 05 In MS Office Category.

  
Question Answered By: Abana Cohen   on Nov 05

I was concerned that this thread was not long enough, so thought I'd
add my own two cents on an alternative:

A Worksheet object has a property called UsedRange which gives you a
range object representing just the portion of the worksheet which has
data in it. Therefore, another way to determine where to put a new
entry in your worksheet would be:

nextrow = ActiveSheet.UsedRange.Rows.Count + 1
Cells(nextrow, 1).Value = NewEntry

(assuming your data starts in the first row)

The advantage to this method is that if you have data in multiple
columns, you'll find  the last used row  regardless of whether or not
there is anything in column 1. If you only look at column 1 to find
the last row used, you could accidentally overwrite a row that has
data in another column, but not in column 1.

If you're still confused about UsedRange, try entering random values
in random cells, then running this small routine:

Sub SelectUsedRange()
ActiveSheet.UsedRange.Select
End Sub

Share: 

 

This Question has 12 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on How to decipher next row? Or get search suggestion and latest updates.


Tagged: