Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Issues with InStr

Your code worked OK for me, but I used simple string data in the cells. Usin
InStr might allow it to read any group of data that matches your search
criteria. It is difficult to tell without knowing what the actual data is.
You could check it by using the tool tips feature to check the value of
Cells(lngRow, 1) on each iteration of the loop by stepping through manually.
That would show you what it is actually reading in the cells. Or just put a
message box in the loop to show what is in that cell on each loop.

"neu2me" wrote:

I am trying to create a macro that looks at a string from one cell and
compares it to each cell in a list on another sheet. If the part of the
string in the list cell contains the contents in the first cell, the entire
contents of the list string is copied into a second area. The code I have is
below...

strKeyword = Sheet1.Cells(6, 2)
For lngRow = 2 To Sheet2.Cells(65536, 1).End(xlUp).Row
If InStr(strKeyword, Sheet2.Cells(lngRow, 1)) 0 Then
Sheet1.Cells(Sheet1.Cells(65536, 2).End(xlUp).Row + 1, 2) =
Sheet2.Cells(lngRow, 1)
End If
Next lngRow

The problem I have is that the computer acts like each list item contains
the contents of my search cell... What am I missing?

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
Instr Karen53 Excel Programming 3 April 2nd 08 01:33 AM
Instr ranswert Excel Programming 2 February 8th 08 12:55 PM
instr() ? mark kubicki Excel Programming 3 November 16th 06 05:07 PM
InStr Harley Excel Programming 3 August 9th 05 08:55 PM
InStr FGM Excel Programming 3 July 14th 05 08:47 PM


All times are GMT +1. The time now is 02:25 PM.

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"