Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default Begin Search at specific cell

Could use a little help with this.

Here's the code that I'm using:

Range("Division").Select
On Error Resume Next
Selection.Find(What:=FindTeamName, After:=ActiveCell, _
MatchCase:=False).Activate
DivNo1 = ActiveCell.Offset(0, -1).Column
Selection.Find(What:=FindTeamName, After:=ActiveCell, _
MatchCase:=False).Activate
DivNo2 = ActiveCell.Offset(0, -1).Column

What I'm trying to accomplish..........
"FindTeamName" may appear once or more in my range
"Divisions" (8 rows by 9 columns).
With my first "Find" above, I want to get the Column -1 of
where it's found. Problem is that I want the second "Find"
to search from where the first is found only to the end of that range.
As of now, if there isn't a second occurance of "FindTeamName"
the second "Find" returns the Column of the first "Find".

Not sure if I explained that well enough?
Any help would be appreciated.

Thanks,
John


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Begin Search at specific cell

Sub AABBCC()
Dim rng As Range, rng1 As Range
Dim rng2 As Range, rng3 As Range
Dim DivNo1, DivNo2
Dim FindTeamName As String
FindTeamName = "A"
Set rng = Range("Division")
Set rng1 = rng.Find(What:=FindTeamName, After:=rng(1), _
MatchCase:=False)
If Not rng1 Is Nothing Then
DivNo1 = rng1.Offset(0, -1).Column
Set rng2 = Range(rng1.Offset(1, 0), rng(rng.Count))
Set rng3 = rng2.Find(What:=FindTeamName, After:=rng2(1), _
MatchCase:=False)
If Not rng3 Is Nothing Then
DivNo2 = rng3.Offset(0, -1).Column
End If
End If
Debug.Print rng1.Address, rng3.Address
Debug.Print DivNo1, DivNo2

End Sub


--
Regards,
Tom Ogilvy



John Wilson wrote in message
...
Could use a little help with this.

Here's the code that I'm using:

Range("Division").Select
On Error Resume Next
Selection.Find(What:=FindTeamName, After:=ActiveCell, _
MatchCase:=False).Activate
DivNo1 = ActiveCell.Offset(0, -1).Column
Selection.Find(What:=FindTeamName, After:=ActiveCell, _
MatchCase:=False).Activate
DivNo2 = ActiveCell.Offset(0, -1).Column

What I'm trying to accomplish..........
"FindTeamName" may appear once or more in my range
"Divisions" (8 rows by 9 columns).
With my first "Find" above, I want to get the Column -1 of
where it's found. Problem is that I want the second "Find"
to search from where the first is found only to the end of that range.
As of now, if there isn't a second occurance of "FindTeamName"
the second "Find" returns the Column of the first "Find".

Not sure if I explained that well enough?
Any help would be appreciated.

Thanks,
John




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default Begin Search at specific cell

Tom,

Thank you

John


"Tom Ogilvy" wrote in message
...
Sub AABBCC()
Dim rng As Range, rng1 As Range
Dim rng2 As Range, rng3 As Range
Dim DivNo1, DivNo2
Dim FindTeamName As String
FindTeamName = "A"
Set rng = Range("Division")
Set rng1 = rng.Find(What:=FindTeamName, After:=rng(1), _
MatchCase:=False)
If Not rng1 Is Nothing Then
DivNo1 = rng1.Offset(0, -1).Column
Set rng2 = Range(rng1.Offset(1, 0), rng(rng.Count))
Set rng3 = rng2.Find(What:=FindTeamName, After:=rng2(1), _
MatchCase:=False)
If Not rng3 Is Nothing Then
DivNo2 = rng3.Offset(0, -1).Column
End If
End If
Debug.Print rng1.Address, rng3.Address
Debug.Print DivNo1, DivNo2

End Sub


--
Regards,
Tom Ogilvy



John Wilson wrote in message
...
Could use a little help with this.

Here's the code that I'm using:

Range("Division").Select
On Error Resume Next
Selection.Find(What:=FindTeamName, After:=ActiveCell, _
MatchCase:=False).Activate
DivNo1 = ActiveCell.Offset(0, -1).Column
Selection.Find(What:=FindTeamName, After:=ActiveCell, _
MatchCase:=False).Activate
DivNo2 = ActiveCell.Offset(0, -1).Column

What I'm trying to accomplish..........
"FindTeamName" may appear once or more in my range
"Divisions" (8 rows by 9 columns).
With my first "Find" above, I want to get the Column -1 of
where it's found. Problem is that I want the second "Find"
to search from where the first is found only to the end of that range.
As of now, if there isn't a second occurance of "FindTeamName"
the second "Find" returns the Column of the first "Find".

Not sure if I explained that well enough?
Any help would be appreciated.

Thanks,
John






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
Search a cell for a specific number mpenkala Excel Worksheet Functions 5 September 24th 08 08:51 PM
count cells that begin with specific text mmer at steelcase Excel Worksheet Functions 7 July 25th 06 09:03 PM
Search for record with specific name in a cell pomalley Excel Worksheet Functions 2 November 17th 05 02:44 PM
How do I search for specific text and sum the cell to the right? PacRat2001 Excel Worksheet Functions 3 October 12th 05 04:21 AM
Search for a specific character in a cell in an if statement mcl Excel Worksheet Functions 2 January 4th 05 09:14 PM


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