ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   code for col number of last used cell in a row (https://www.excelbanter.com/excel-discussion-misc-queries/262604-code-col-number-last-used-cell-row.html)

Jack Sons

code for col number of last used cell in a row
 
Hi all,

I knew it once, but I didn't program for a long time:
What is the best code to get the column number (number!) of the last non
blank cell in a row?
TIA

Jack Sons
The Netherlands




Bob Phillips[_4_]

code for col number of last used cell in a row
 
Assuming row 1

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

--

HTH

Bob

"Jack Sons" wrote in message
...
Hi all,

I knew it once, but I didn't program for a long time:
What is the best code to get the column number (number!) of the last non
blank cell in a row?
TIA

Jack Sons
The Netherlands






ozgrid.com

code for col number of last used cell in a row
 
Dim lCol as Long

lCol=Cells(1,Columns.Count).End(XlToLeft)).Column



--
Regards
Dave Hawley
www.ozgrid.com
"Jack Sons" wrote in message
...
Hi all,

I knew it once, but I didn't program for a long time:
What is the best code to get the column number (number!) of the last non
blank cell in a row?
TIA

Jack Sons
The Netherlands





Mike H

code for col number of last used cell in a row
 
Hi

The 1 represents row 1 so change to suit

LastCol = Cells(1, Columns.Count).End(xlToLeft).Column
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Jack Sons" wrote:

Hi all,

I knew it once, but I didn't program for a long time:
What is the best code to get the column number (number!) of the last non
blank cell in a row?
TIA

Jack Sons
The Netherlands



.


Jack Sons

code for col number of last used cell in a row
 
Bob, Dave and Mike, thank you all.

Jack.

"Jack Sons" schreef in bericht
...
Hi all,

I knew it once, but I didn't program for a long time:
What is the best code to get the column number (number!) of the last non
blank cell in a row?
TIA

Jack Sons
The Netherlands







All times are GMT +1. The time now is 02:24 PM.

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