ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Last column... (https://www.excelbanter.com/excel-programming/395769-last-column.html)

Darin Kramer

Last column...
 
Hi all,

Im sure ive done this before, but cant get it to work now!

I want to find the last column (ie start at IJ go left until find last
column with data in it. I then want to delete from IJ up to 1 + the last
column!

Any ideas ?

Thanks

D

Ps - Dave the one for rows works great!



*** Sent via Developersdex http://www.developersdex.com ***

Dave Peterson

Last column...
 
Can you pick out a row that always has data in it if that column is used?

I used row 1:

Dim NextCol As Long
With ActiveSheet
NextCol = .Cells(1, .Columns.Count).End(xlToLeft).Column + 1
.Range(.Columns(NextCol), .Columns(.Columns.Count)).EntireColumn.Delete
End With

And why end at IJ? I used all the columns (IV in xl2003 and below).

But if you want...

Dim NextCol As Long
With ActiveSheet
NextCol = .Cells(1, "IJ").End(xlToLeft).Column + 1
.Range(.Columns(NextCol), .Columns("IJ:IJ")).EntireColumn.Delete
End With


Darin Kramer wrote:

Hi all,

Im sure ive done this before, but cant get it to work now!

I want to find the last column (ie start at IJ go left until find last
column with data in it. I then want to delete from IJ up to 1 + the last
column!

Any ideas ?

Thanks

D

Ps - Dave the one for rows works great!

*** Sent via Developersdex http://www.developersdex.com ***


--

Dave Peterson

Darin Kramer

Last column...
 


Great! Thanks

*** Sent via Developersdex http://www.developersdex.com ***


All times are GMT +1. The time now is 07:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com