LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default Find next without activating First cell Address

Hi again.


In My following code how can I limit the search in CurRange?

also running the code from sheet1 while the named ranges are in sheet2
is it possible to find the Next Occurance without Activating any
CellIs?

In my code i have to activate both FirstCell and NextCell.

Thabks for your help.

Sub FindWord(WhatToFind As Variant)

Dim FirstCell As Range
Dim NextCell As Range
Dim CurRange As Range
Dim CountFound As Long
Dim i As Integer

Application.ScreenUpdating = False

If CmbAraEng = "Arabic" Then
Set CurRange = Range("Arabic")
ElseIf CmbAraEng = "English" Then
' Set CurRange = Range("English")
ElseIf CmbAraEng = "Malayalam" Then
' Set CurRange = Range("Malayalam")
ElseIf CmbAraEng = "Urdu" Then
Set CurRange = Range("Urdu")
End If

With CurRange

If WhatToFind < "" Then
Set FirstCell = Cells.Find(What:=WhatToFind,
LookIn:=xlValues, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False)
If Not FirstCell Is Nothing Then
FirstCell.Activate
i = LstFind.ListCount
LstFind.AddItem FirstCell.Address
CountFound = CountFound + 1

LstFind.List(i, 1) = Cells(FirstCell.Row, 1).Value
LstFind.List(i, 2) = Cells(FirstCell.Row, 2).Value
LstFind.List(i, 3) = Cells(FirstCell.Row, 3).Value

CountFound = CountFound + 1
On Error Resume Next
While (Not NextCell Is Nothing) And (Not
NextCell.Address = FirstCell.Address)
Set NextCell = Cells.FindNext(After:=X)
If Not NextCell.Address = FirstCell.Address
Then
NextCell.Activate
i = LstFind.ListCount
LstFind.AddItem NextCell.Address

LstFind.List(i, 1) = Cells(NextCell.Row, 1).Value
LstFind.List(i, 2) = Cells(NextCell.Row, 2).Value
LstFind.List(i, 3) = Cells(NextCell.Row, 3).Value
CountFound = CountFound + 1
End If
Wend
End If
Set NextCell = Nothing
Set FirstCell = Nothing


End If
LblCount.Caption = CountFound & " Matche(s) Found"

On Error Resume Next
Application.ScreenUpdating = True
End Sub

 
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
How do I find address of cell containing maximum value Doug Excel Worksheet Functions 11 April 14th 08 02:14 PM
find last cell in range with data, display cell address sevi61 Excel Worksheet Functions 14 October 29th 07 08:36 PM
Excel: "De-activating" an e-mail address cell? HowdyPete Excel Discussion (Misc queries) 2 August 17th 06 04:18 PM
Is there a way to find the address of a cell with a certain value? Oshtruck user Excel Worksheet Functions 1 August 10th 06 07:57 PM
Function to find the address of a cell Ron Rosenfeld Excel Worksheet Functions 23 December 11th 05 04:06 PM


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