find last column

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
thanks a lot bob..for a very quick response and a
wonderful solution

thanks again!
 

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

Back
Top