Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm searching a column for matches (FindThis) and writing to cells on
the row (WriteReason) on success. The macro below works fine, but my number of matching terms is increasing and I find myself just copying and pasting the code over and over again. Is there a better way to modularize this just plug in values without creating "FindThisA, FindThisB", etc? ---- Sub Exclusions() WriteManual = "Manual" Const FindThisA = "MatchA" Const WriteReasonA = "Failure Code A" Const FindThisB = "MatchB" Const WriteReasonB = "Failure Code B" Dim A As Range, retA ActiveCell.EntireColumn.Select For Each A In Selection retA = InStr(1, A, FindThisA, vbTextCompare) If (Not IsNull(retA)) And (retA 0) Then A.Offset(0, -17).Value = WriteReasonA A.Offset(0, -20).Value = WriteManual End If Next A Dim B As Range, retB ActiveCell.EntireColumn.Select For Each B In Selection retB = InStr(1, B, FindThisB, vbTextCompare) If (Not IsNull(retB)) And (retB 0) Then B.Offset(0, -17).Value = WriteReasonB B.Offset(0, -20).Value = WriteManual End If Next B End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
reusing code | Excel Programming | |||
Reusing Form Code | Excel Programming | |||
Reusing formula | Excel Discussion (Misc queries) | |||
Reusing grouping of non-adjacent cells | Excel Discussion (Misc queries) | |||
reusing a recordset for a pivot-table? | Excel Programming |