Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default find last column

how can i find the last column in a particular row.
To fidn the last column in a the sheet we find thru:
With ActiveSheet.UsedRange
lastColSum = .Column + .Columns.Count - 1
End With
but what if i want to find in a particular row?

thanks in advance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default find last column

Sub FindLastEmptyCellInRow1()
Dim rng As Range
'find the last cell in row 1 with something in it.
Set rng = Rows(1).Cells.Find("*", , , xlPart, xlByColumns, xlPrevious,
False)
If rng Is Nothing Then
'no occupied cells
MsgBox "Column: #1"
Else
If rng.Column = Columns.count Then
MsgBox "Last cell is full"
Else
MsgBox "Column: #" & rng.Column + 1
End If
End If
Set rng = Nothing
End Sub

wrote in message
...
how can i find the last column in a particular row.
To fidn the last column in a the sheet we find thru:
With ActiveSheet.UsedRange
lastColSum = .Column + .Columns.Count - 1
End With
but what if i want to find in a particular row?

thanks in advance



  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default find last column

thanks a lot bob..for a very quick response and a
wonderful solution

thanks again!
-----Original Message-----
Sub FindLastEmptyCellInRow1()
Dim rng As Range
'find the last cell in row 1 with something in it.
Set rng = Rows(1).Cells.Find("*", , , xlPart,

xlByColumns, xlPrevious,
False)
If rng Is Nothing Then
'no occupied cells
MsgBox "Column: #1"
Else
If rng.Column = Columns.count Then
MsgBox "Last cell is full"
Else
MsgBox "Column: #" & rng.Column + 1
End If
End If
Set rng = Nothing
End Sub

wrote in message
...
how can i find the last column in a particular row.
To fidn the last column in a the sheet we find thru:
With ActiveSheet.UsedRange
lastColSum = .Column + .Columns.Count - 1
End With
but what if i want to find in a particular row?

thanks in advance



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default find last column

Also try


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

--
Message posted from http://www.ExcelForum.com

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
FInd common data in one column then add number in adjacent column JT Excel Worksheet Functions 3 December 18th 09 10:20 PM
find last row value in column when using MATCH to find column Bouce Excel Worksheet Functions 6 February 6th 08 10:16 PM
Find something in column a then find if column B matches criteria Darrell_Sarrasin via OfficeKB.com Excel Discussion (Misc queries) 8 November 28th 07 09:40 PM
Find First Non blank cell than find column header and return that value Silver Rose Excel Worksheet Functions 10 April 30th 07 05:56 PM
How to find the most recent date in a column based on other column Veretax Excel Worksheet Functions 7 October 18th 06 05:01 PM


All times are GMT +1. The time now is 11:28 AM.

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

About Us

"It's about Microsoft Excel"