Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Finding Last Column in a given Row

Hello,

How do I find the last nonempty column in a given row (say row 2)?

Lance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default 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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default Finding Last Column in a given Row

oops, this will give you the last non-empty cell in the last ROW.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default 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





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
finding the largest value for a name in a column and then returningthe result from a different column [email protected] Excel Worksheet Functions 1 April 14th 08 10:08 AM
Finding a number in a column out of an array in another column cirena Excel Discussion (Misc queries) 3 April 4th 07 06:30 PM
Finding Info from Column A and Removing it from Column B Johnny B[_2_] Excel Discussion (Misc queries) 2 March 28th 07 12:06 PM
Output from a userform finding the right column. column HelpMe Excel Programming 1 February 10th 04 03:27 PM
finding and reporting in column A, where a series of column reaches zero Gary Tamblyn Excel Programming 2 July 27th 03 12:00 PM


All times are GMT +1. The time now is 04:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"