Is there an easier way



I have a "souce sheet" with two columns, one has a "name", the other a
I will have all the names in a list

So I will loop through the list, get each name in turn, then find the
matching name row on the Source sheet and get the associated number - enter
where needed on target sheet

I don't know an easier way than looping through the whole source sheet name
each time looking for a match to the "target name"

The names will probably be in the same order in my target list as in the
source sheet column
but it seems better programming not to rely on that being true necessarily.
If they were guaranteed to match I could use an index number and just
increment that for the
next row to check, but is there a more direct way?

Kind of like an sql statement something like(pseudocode) Get colB Where
colA.Value = TargetName

without having to repeatedly loop through the entire list each time?
(hope that was clear)


here's the wasteful way, looping through the entire column on source sheet
each time
For lTicker = 0 To oDict.Count - 1
Ticker = oDict.KeyByIndex(lTicker)
For lSource = StartRow To LastRow
With SourceSht
If Trim(.Cells(lSource, "A").Value) = Trim(Ticker) Then
LastPrice = .Cells(lSource, "C").Value
Exit For
End If
End With
Next lSource
Next lTicker

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question