Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Return ROW number from qa found range

I have the following:

Columns("A:A").Select
Selection.Find(What:="Alabama", After:=ActiveCell, LookIn:=xlFormulas,
lookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False).Activate

Now want to have a variable equal to the Row number that it finds the text.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Return ROW number from qa found range

Try something like

Dim FoundCell As Range
Dim WhatRow As Long
Columns("A:A").Select
Set FoundCell = Selection.Find(What:="Alabama",
After:=ActiveCell, _
LookIn:=xlFormulas, lookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)
If FoundCell Is Nothing Then
MsgBox "Not Found"
Else
WhatRow = FoundCell.Row
MsgBox "Found in row: " & WhatRow
End If



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Mike" wrote in message
...
I have the following:

Columns("A:A").Select
Selection.Find(What:="Alabama", After:=ActiveCell,
LookIn:=xlFormulas,
lookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False).Activate

Now want to have a variable equal to the Row number that it
finds the text.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Return ROW number from qa found range

Hi Mike,

rownumber=activecell.row

in your case

Regards,
Ivan

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Return ROW number from qa found range

One way:

Given your existing code:

nRow = ActiveCell.Row

Perhaps a better way:

Dim nRow As Long
Dim rFound As Range
Set rFound = Range("A:A").Find( _
What:="Alabama", _
After:=Range("A1"), _
LookIn:=xlFormulas, _
LookiAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not rFound Is Nothing Then
nRow = rFound.Row
Else
MsgBox "'Alabama' was not found in column A"
End If





In article ,
Mike wrote:

I have the following:

Columns("A:A").Select
Selection.Find(What:="Alabama", After:=ActiveCell, LookIn:=xlFormulas,
lookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False).Activate

Now want to have a variable equal to the Row number that it finds the text.

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
return next highest number in range Code Numpty Excel Worksheet Functions 6 April 21st 11 08:19 PM
Search multiple sheets and return largest number found mpenkala Excel Worksheet Functions 2 January 4th 07 04:41 PM
Return Result If Number Is Within Range MDW Excel Worksheet Functions 2 October 20th 06 03:41 PM
Return ROW value for range found Mike Excel Programming 0 April 26th 06 02:35 PM
how to return a certain value if a number is within a range Caconz Excel Discussion (Misc queries) 5 February 16th 06 04:33 AM


All times are GMT +1. The time now is 01:56 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"