Finding last non-empty column in row...

M

Mika

This code works fine:
MsgBox Cells(Rows.Count, "A").End(xlUp).Row

But this does not:
MsgBox Cells(Columns.Count, "2").End(xlLeft).Column

Any ideas how it should be changed to work?

Thanks!
Mika.
 
S

shockley

MsgBox Cells(Columns.Count, "2").End(xlLeft).Column

should be xlToLeft rather than xlLeft
 
M

mudraker

MsgBox Cells(1, Columns.Count).End(xlToLeft).Column

don't forget when using cells command use numbers without ""

cells(row number,column number)

or
cells(row number, "column letter")
 

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

Top