ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Finding last non-empty column in row... (https://www.excelbanter.com/excel-programming/282211-finding-last-non-empty-column-row.html)

Mika[_3_]

Finding last non-empty column in row...
 
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.



shockley

Finding last non-empty column in row...
 
MsgBox Cells(Columns.Count, "2").End(xlLeft).Column

should be xlToLeft rather than xlLeft

"Mika" wrote in message
...
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.





mudraker[_7_]

Finding last non-empty column in row...
 

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")


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/



All times are GMT +1. The time now is 12:47 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com