search cells in multiple columns of same row
I see you have another thread with the same question.
Good luck.
Dave Peterson wrote:
Maybe something like:
Option Explicit
Sub testme()
Dim res As Variant
Dim wks As Worksheet
Dim WhatToFind As String
Dim iCol As Long
Set wks = Worksheets("sheet1")
WhatToFind = "JACK And JILL"
With wks
res = Application.Match(WhatToFind, .Range("H:H"), 0)
If IsError(res) Then
MsgBox "not found"
Exit Sub
End If
For iCol = 1 To 6 'skip 7 not to overwrite column 7
If LCase(.Cells(res, iCol).Value) = LCase("x") Then
.Cells(res, iCol + 1).Value = "X"
Exit For
End If
Next iCol
End With
End Sub
jsd219 wrote:
I am trying to write a script that looks for a cell with specified text
in a specified column, once it finds the cell it needs to check six
different columns (a,b,c,d,e,f) one row above and find the column that
has an "x", it then needs to place an "x" in its row one column to the
right form the previous "x"
example: if it finds the cell with "Went up the hill" the script needs
to look up one row and check columns (a,b,c,d,e,f) until it finds the
"X".
In this case it will find the "X" on the row with "JACK AND JILL" in
column "a" so it will place an "X" for the row "Went up the hill" (the
orginal cell searched for) in column "b"
a b c d e f g
X JACK AND JILL
Went up the hill
To fetch 3.5 Pales of
Water
God bless
jsd219
--
Dave Peterson
--
Dave Peterson
|