find last column
how can i find the last column in a particular row.
To fidn the last column in a the sheet we find thru: With ActiveSheet.UsedRange lastColSum = .Column + .Columns.Count - 1 End With but what if i want to find in a particular row? thanks in advance |
find last column
Sub FindLastEmptyCellInRow1()
Dim rng As Range 'find the last cell in row 1 with something in it. Set rng = Rows(1).Cells.Find("*", , , xlPart, xlByColumns, xlPrevious, False) If rng Is Nothing Then 'no occupied cells MsgBox "Column: #1" Else If rng.Column = Columns.count Then MsgBox "Last cell is full" Else MsgBox "Column: #" & rng.Column + 1 End If End If Set rng = Nothing End Sub wrote in message ... how can i find the last column in a particular row. To fidn the last column in a the sheet we find thru: With ActiveSheet.UsedRange lastColSum = .Column + .Columns.Count - 1 End With but what if i want to find in a particular row? thanks in advance |
find last column
thanks a lot bob..for a very quick response and a
wonderful solution thanks again! -----Original Message----- Sub FindLastEmptyCellInRow1() Dim rng As Range 'find the last cell in row 1 with something in it. Set rng = Rows(1).Cells.Find("*", , , xlPart, xlByColumns, xlPrevious, False) If rng Is Nothing Then 'no occupied cells MsgBox "Column: #1" Else If rng.Column = Columns.count Then MsgBox "Last cell is full" Else MsgBox "Column: #" & rng.Column + 1 End If End If Set rng = Nothing End Sub wrote in message ... how can i find the last column in a particular row. To fidn the last column in a the sheet we find thru: With ActiveSheet.UsedRange lastColSum = .Column + .Columns.Count - 1 End With but what if i want to find in a particular row? thanks in advance . |
find last column
Also try
LastCol = Cells(1, Columns.Count).End(xlToLeft).Colum -- Message posted from http://www.ExcelForum.com |
All times are GMT +1. The time now is 06:37 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com