find last column with data

  • Thread starter Thread starter thomas donino
  • Start date Start date
T

thomas donino

I have a file that at times will have various number of columns. How do I
find the last column with data. All rows will have data in the same columns.
I am starting at A2
 
hi
try somedthing like this......
Sub findcol()
Dim c As Long
c = Cells(1, Columns.Count).End(xlToLeft).Column
MsgBox "The Last column is " & Cells(1, c).Address
'Cells(1, c).Select 'optional
End Sub

regards
FSt1
 
here's a solution from rick rothstein:

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

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

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