Last Column


S

Striker

How can I find the last column and then delete that range from A2 to end of
the file?

I can find the last row by
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
set Range = ("A2:???" & LastRow)

Can't seem to find the last column then clear that range. Say the last
column is Q, and the last row is 3008. I need to clear from A2 to Q3008
 
Ad

Advertisements

R

Rick Rothstein

The method you are using requires you to know the column containing the
actual last piece of data. Here is a different method that identifies the
last row containing data no matter what column that piece of data appears in
and, using a similar statement format, here is also a method of finding
column containing the last piece of data, no matter what row it is in...

LastUsedRow = ActiveSheet.Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlRows).Row

LastUsedColumn = ActiveSheet.Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByColumns).Column

Then you can delete the information in those cells using this...

Range(Cells(2,1), Cells(LastUsedRow, LastUsedColumn)).Clear
 
Ad

Advertisements


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

Top