Posted to microsoft.public.excel.programming
|
|
Find Match and count order
Hi,
Try this. I got slightly confused as whether data was only in column
DX or both DX and EX. This loops through DX but you modify to add EX.
Sub FindHpos()
For i = 63 To 116
col = 187 ' GE
srchstring = Replace(Range("DX" & i), ",", "") ' Remove ,
Do While InStr(1, srchstring, "H") < 0
n = InStr(1, srchstring, "H") ' position of H
Cells(i, col) = n
col = col + 1
srchstring = Replace(srchstring, "H", "X", 1, 1) ' replace next H
with X
Loop
Next i
End Sub
HTH
"dkenebre" wrote:
How do I automate the following example with code:
Sample data
DX63:EX63 H,O,O,O,H,H,O,O,O,O,O,O,O,O,O,O,H,O,O,O,H,O,O,O,O, H,O
DX64:DX64 H,O,O,O,H,O,O,O,H,O,O,O,O,O,O,H,O,O,O,O,H,O,O,O,O, H,H
Result
GE63:GJ63 = 1, 5, 6, 17, 21, 26
GE64:GK64 = 1, 5, 9, 16, 21, 26, 27
Apply for each source data row within the range DX63:EX116,
and place the output for each row in the range GE63:GM116
Record the order of each H within the range of each row of the source
range.
--
dkenebre
------------------------------------------------------------------------
dkenebre's Profile: http://www.excelforum.com/member.php...nfo&userid=760
View this thread: http://www.excelforum.com/showthread...hreadid=394715
|