Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 852
Default Using Find as lookup method goes to semi endless loop

On Sunday, June 22, 2014 4:19:00 AM UTC-7, Claus Busch wrote:
Hi Howard,



Am Sun, 22 Jun 2014 03:53:03 -0700 (PDT) schrieb L. Howard:



I just so happened I had dispersed some sample test strings on the sheet all of which are with in the range od D4:H22.




then set your range and the start cell explicit:


Thar works fine.
You are a champion! Nice and thanks.

Regards,
Howard
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Using Find as lookup method goes to semi endless loop

Hi Howard,

Am Sun, 22 Jun 2014 04:27:39 -0700 (PDT) schrieb L. Howard:

Thar works fine.


to make the code a bit more universal you can also work with UsedRange:

Sub MyBadFoodFind4()

Dim i As Long, j As Long, n As Long
Dim MyArr As Variant, arrCheck As Variant, arrRng As Variant
Dim LRow As Long, LCol As Long
Dim iRet As Integer
Dim strPrompt As String, strRng As String
Dim strTitle As String, myStr As String
Dim StartC As Range
Dim OffRow As Long, OffCol As Long

With Sheets("Sheet1")
.UsedRange.Interior.ColorIndex = xlNone

strPrompt = " Highlights have been removed." & vbCr & _
"If you want to continue click ""Yes."""

strTitle = "My Bad Eats"

iRet = MsgBox(strPrompt, vbYesNo, strTitle)

If iRet = vbNo Then
Exit Sub
Else
'
End If

MyArr = Array("milk", "soda", "fries", "pizza", "beer", "chips", _
"candy", "alcohol", "mcdonalds", "wendys", "burger king")

strRng = .UsedRange.Address(0, 0)
arrRng = Split(strRng, ":")
Set StartC = .Range(arrRng(0))
OffRow = StartC.Row - 1
OffCol = StartC.Column - 1

arrCheck = .UsedRange
LCol = .UsedRange.Columns.Count
LRow = .UsedRange.Rows.Count

Application.ScreenUpdating = False

For j = LBound(MyArr) To UBound(MyArr)
If WorksheetFunction.CountIf(.UsedRange, "*" & MyArr(j) & "*") =
0 Then
myStr = myStr & MyArr(j) & Chr(10)
GoTo NextLoop
Else
For i = 1 To LRow
For n = 1 To LCol
If InStr(LCase(arrCheck(i, n)), MyArr(j)) Then
.Cells(i + OffRow, n +
OffCol).Interior.ColorIndex = 6
End If
Next n
Next i
End If
NextLoop:
Next j
End With

Application.ScreenUpdating = True
If Len(myStr) 0 Then
MsgBox "No matches found for:" & Chr(10) & myStr
End If

End Sub


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 852
Default Using Find as lookup method goes to semi endless loop

On Sunday, June 22, 2014 5:02:52 AM UTC-7, Claus Busch wrote:
Hi Howard,



Am Sun, 22 Jun 2014 04:27:39 -0700 (PDT) schrieb L. Howard:



Thar works fine.




to make the code a bit more universal you can also work with UsedRange:


Regards

Claus B.

--



Great, now one can either set the 'search' area to exclude certain cells using code ...3() or go with UsedRange for all cells using code ...4().

Thanks again Claus.

Regards,
Howard
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 Method vs. For...Next Loop mikelee101[_2_] Excel Programming 3 July 10th 08 09:43 PM
Find Method in For Loop Sisilla[_2_] Excel Programming 3 May 3rd 07 08:02 PM
Endless loop freddie mac Excel Programming 2 August 1st 06 03:19 PM
endless loop help John Excel Programming 1 October 26th 05 04:51 PM
Endless loop? John Excel Programming 24 August 2nd 05 06:41 PM


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