![]() |
Finding Last Column in a given Row
Hello,
How do I find the last nonempty column in a given row (say row 2)? Lance |
Finding Last Column in a given Row
Hi, this function will give you the last non-empty cell in the last
column, just change the variable myRow to the row value as you need. Function LastCell(Optional ws As Worksheet) As Range Dim myRow&, myCol&, Rng As Range If ws Is Nothing Then Set ws = ActiveSheet Set Rng = ws.Cells Set LastCell = Rng(1) myRow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row myCol = ActiveSheet.Cells(myRow, Columns.Count) _ ..End(xlToLeft).Column On Error Resume Next Set LastCell = Intersect(Rows(myRow), Columns(myCol)) End Function HTH--Lonnie M. |
Finding Last Column in a given Row
oops, this will give you the last non-empty cell in the last ROW.
|
Finding Last Column in a given Row
numbers or letters?
formula or macro? -- Don Guillett SalesAid Software "Lance Hoffmeyer" wrote in message ... Hello, How do I find the last nonempty column in a given row (say row 2)? Lance |
Finding Last Column in a given Row
Consider:
lastCell = Activesheet.Cells(2,Columns.Count).End(xltoLeft) Lance Hoffmeyer wrote: Hello, How do I find the last nonempty column in a given row (say row 2)? Lance |
Finding Last Column in a given Row
Cells(2,256).End(xltoLeft).Column
-- Regards, Tom Ogilvy "Lance Hoffmeyer" wrote in message ... Hello, How do I find the last nonempty column in a given row (say row 2)? Lance |
All times are GMT +1. The time now is 12:16 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com