ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Find last column with data? (https://www.excelbanter.com/excel-discussion-misc-queries/225779-find-last-column-data.html)

Myles

Find last column with data?
 
Okay guys so i tried to convert some code i found for last Row with text in
it..

Function LastColumn(Row As String)
LastColumn = Range(Columns.Count & Row).End(xlToRight).Column
End Function

But i get an error when trying to use it

Does anybody know how to convert this to get the last column with text with
the Row is supplied?

Thanks!!

Mike H

Find last column with data?
 
Hi,

Try this

LastCol = ActiveSheet.Cells(2, Columns.Count).End(xlToLeft).Column

the 2 represents row 2 so change to suit

Mike

"Myles" wrote:

Okay guys so i tried to convert some code i found for last Row with text in
it..

Function LastColumn(Row As String)
LastColumn = Range(Columns.Count & Row).End(xlToRight).Column
End Function

But i get an error when trying to use it

Does anybody know how to convert this to get the last column with text with
the Row is supplied?

Thanks!!


Myles

Find last column with data?
 
I'm sorry, i meant last COLUMN that has text in it on one specific row. So
basically i know what row i want to look on, i just need to find out which
column it is and convert it to the letter.

Thanks!!



"Myles" wrote:

Okay guys so i tried to convert some code i found for last Row with text in
it..

Function LastColumn(Row As String)
LastColumn = Range(Columns.Count & Row).End(xlToRight).Column
End Function

But i get an error when trying to use it

Does anybody know how to convert this to get the last column with text with
the Row is supplied?

Thanks!!


Don Guillett

Find last column with data?
 
try it this way
Function LastColumn(x)
LastColumn = Cells(x, Columns.Count).End(xlToLeft).Column
End Function

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Myles" wrote in message
...
Okay guys so i tried to convert some code i found for last Row with text
in
it..

Function LastColumn(Row As String)
LastColumn = Range(Columns.Count & Row).End(xlToRight).Column
End Function

But i get an error when trying to use it

Does anybody know how to convert this to get the last column with text
with
the Row is supplied?

Thanks!!




All times are GMT +1. The time now is 04:57 AM.

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