Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Finding value and returning row number


Hi,

I was wondering what command(s) would be best for finding a value's row
and returning it as an integer?

Thanks!
Merritts


--
merritts
------------------------------------------------------------------------
merritts's Profile: http://www.excelforum.com/member.php...o&userid=35803
View this thread: http://www.excelforum.com/showthread...hreadid=564512

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Finding value and returning row number


Hello Merritts,

There are a few ways to do this...

Code:
--------------------

1) Using the Active Cell
R = ActiveCell.Row

2) Using a Range to find the First Row
R = Range("A2") 'R = 2
R = Range("A34:Z1250") 'R = 34, the first row in the range

3) Using a Range to find the Last Row
With Worksheets("Sheet1") 'R = last non blank cell in column A on Worksheet1
R = .Cells(.Rows.Count, "A").End(xlUp).Row
End With

--------------------


Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=564512

  #3   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Finding value and returning row number

You could also use the Find method

For example, to search Sheet1 for the word "Test":

Sub test()
Const strCriteria = "Test"
Dim rngCell As Range

With Worksheets("Sheet1")
Set rngCell = .Cells.Find(What:=strCriteria, _
After:=.Cells(1, 1), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)
End With

If Not rngCell Is Nothing Then _
MsgBox rngCell.Row

End Sub

Check VBA help for more information as you may need to change some of the
search parameters.

"merritts" wrote:


Hi,

I was wondering what command(s) would be best for finding a value's row
and returning it as an integer?

Thanks!
Merritts


--
merritts
------------------------------------------------------------------------
merritts's Profile: http://www.excelforum.com/member.php...o&userid=35803
View this thread: http://www.excelforum.com/showthread...hreadid=564512


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 a value and returning corresponding info OssieMac Excel Discussion (Misc queries) 1 December 31st 09 01:16 AM
Finding a Name on a list and returning all matching rows Wh0o Excel Worksheet Functions 2 August 18th 09 05:52 PM
Finding a cell and returning value from a different row and column RJBohn3 Excel Discussion (Misc queries) 1 May 23rd 09 01:13 AM
Finding an item in a list & returning a specific value SBW Excel Worksheet Functions 7 April 20th 09 09:54 PM
Finding, and returning data. Marcus New Users to Excel 1 June 3rd 05 07:48 PM


All times are GMT +1. The time now is 01:50 AM.

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"