How to know the right most column?

G

Guest

Dear all,

I would like to know how to get the right most column number whose cell has
a value in a row. Can anyone suggest how to do it programatically?
Thanks a lot.

Ivan
 
N

Norman Jones

Hi Ivan,

For a specific row, try

LastColInRow = Cells(1, Columns.Count).End(xlToLeft).Column

MsgBox LastInCol

Replace 1 with the required row number.
 
G

Guest

Hi Ivan,

Try:

With ActiveSheet.UsedRange
MsgBox .Column + .Columns.Count - 1
End With

HTH
 

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