![]() |
Last Column
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 |
Last Column
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 -- Rick (MVP - Excel) "Striker" wrote in message ... 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 |
Last Column
Maybe
LastCol=Range("A" & Columns.count).end(xltoleft).Column Regards, Per "Striker" skrev i meddelelsen ... 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 |
All times are GMT +1. The time now is 11:14 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com