column.count 99

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

Guest

Can anyone provide the syntax for counting the number of columns containing
data in an unknown range? The row.count syntax is:
lastrow = Worksheets(1).Cells(Rows.Count, 2).End(xlUp).Row
lastcolumn=???

I need to find the last column with data in a worksheet that could contain
any number of columns.
 
You used column B to find the last row.

Can you pick out a row to find the last column (maybe row 1 has headers???):

dim LastRow as long
dim LastCol as long

With worksheets(1)
lastrow = .Cells(Rows.Count, 2).End(xlUp).Row
lastcol = .cells(1,.columns.count).end(xltoleft).column
end with
 

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