Fix code to put a "+" if Pass and a "-" if Fail

Status
Not open for further replies.

Nlhicks

Board Regular
Joined
Jan 8, 2021
Messages
244
Office Version
  1. 365
Platform
  1. Windows
Code so far that is not quite working like I would like it to, the bolded section is where I think the problem lies:
Sub Test2()
If ActiveSheet.Name <> "Sheet2" Then
MsgBox "Run this from the Sheet 2.", 64, "Note:"
Exit Sub
End If

Application.ScreenUpdating = False
Dim cellEstelle As Range, strEstelle$, strPassFail$
Dim varFindScenario As Variant, lngFindScenario&, lngNextCol&, xCol&

With Sheets("Sheet1")

For Each cellEstelle In Columns(1).SpecialCells(2)
Set varFindScenario = Nothing
strEstelle = cellEstelle.Value
Set varFindScenario = .Columns(8).Find(What:=strEstelle, LookIn:=xlFormulas, LookAt:=xlWhole)

If Not varFindScenario Is Nothing Then
lngFindScenario = varFindScenario.Row
'Modify thse column number boundaries as needed.
If lngFindScenario >= 9 And lngFindScenario <= 16 Then
If Cells(cellEstelle.Row, 2).Value = "Pass" Then
strPassFail = "+"
Else
strPassFail = "-"
End If

For xCol = 6 To 20
If Len(.Cells(xCol, lngFindScenario).Value) = 0 And .Cells(xCol, lngFindScenario).Interior.ColorIndex = -4142 Then .Cells(xCol, lngFindScenario).Value = strPassFail
Next xCol

End If
End If
Next cellEstelle

End With

Set varFindScenario = Nothing
Application.ScreenUpdating = True
MsgBox "Completed.", , "Done."
End Sub




Sheet1:
Test Tracking Test2 adding new section.xlsm
HIJKLMNOP
6D_ANT_SFTY_01
7D_ANT_SFTY_02
8D_ANT_SFTY_03
9BITO_1010
10BITO_1011
11BITO_1012
12BITO_1013
13QNTI_01
14QNTI_02
15QNTI_03
16PLT_555
17PLT_556
18PLT_557
19DPIP_01
Sheet1


Sheet2:
Test Tracking Test2 adding new section.xlsm
AB
1One
2D_ANT_SFTY_01Pass
3D_ANT_SFTY_02Fail
4D_ANT_SFTY_03Pass
5BITO_1010Pass
6BITO_1011Pass
7BITO_1012Pass
8BITO_1013Pass
9QNTI_01Pass
10QNTI_02Fail
11QNTI_03Pass
12PLT_555Pass
13PLT_556Pass
14PLT_557Pass
15DPIP_01Fail
Sheet2
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Status
Not open for further replies.

Forum statistics

Threads
1,215,064
Messages
6,122,941
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top