The document describes a VBA macro that fills cells in a range with the letter S based on matches between values in two different ranges. The macro uses loops to compare each cell in one range to each cell in another range and checks for matches using wildcard patterns, filling the corresponding cell when a match is found.
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
6 views
Fill Routine
The document describes a VBA macro that fills cells in a range with the letter S based on matches between values in two different ranges. The macro uses loops to compare each cell in one range to each cell in another range and checks for matches using wildcard patterns, filling the corresponding cell when a match is found.
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1
Sub FillRoutine()
Dim EffectRange As Range
Dim Col As Range Dim CauseRange As Range Dim ThisCell1 As Range Dim ThisCell2 As Range Dim LRow As Long Dim LColumn As Long
LRow = Cells(Rows.Count, 1).End(xlUp).Row
Set CauseRange = Application.Selection
Application.ScreenUpdating = False
'Range("Q1").Select 'Selection.EntireColumn.Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select Set EffectRange = Range("Q4:IN4")
For Each ThisCell1 In Range("A6:A1529")
For Each ThisCell2 In Range("A1536:A" & LRow) If ThisCell1.Value Like ThisCell2.Value + "*PVHH*" Or _ ThisCell1.Value Like ThisCell2.Value + "*ZSC_HMI*" Or _ ThisCell1.Value Like ThisCell2.Value + "*ZSO_HMI*" Or _ ThisCell1.Value Like ThisCell2.Value + "*AlarmOut*" Or _ ThisCell1.Value Like ThisCell2.Value + "*PVLL*" Then ThisCell1.Offset(0, (EffectRange.Find("R006").Column) - 1).Value = "S" On Error Resume Next Exit For End If Next ThisCell2 Next ThisCell1 On Error Resume Next Application.ScreenUpdating = True End Sub