Changing code to mark requirement "+" for pass and "-" for fail under each scenario that was run and leave it blank otherwise

Nlhicks

Board Regular
Joined
Jan 8, 2021
Messages
244
Office Version
  1. 365
Platform
  1. Windows
Option Explicit

Sub Test2()
If ActiveSheet.Name <> "Sheet4" Then
MsgBox "Run this from the Sheet 4.", 64, "Note:"
Exit Sub
End If

Application.ScreenUpdating = False

Dim cellEstelle As Range, strEstelle$, strPassFail$
Dim varFindRequirement As Variant, lngFindRequirement&, lngNextCol&, xCol&
Dim cellEasy As Range, strEasy$
Dim varFindScenario As Variant, lngFindScenario&, lngNextRow&, xRow&

With Sheets("Sheet3")

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

For Each cellEasy In Columns(3).SpecialCells(2)
Set varFindScenario = Nothing
strEasy = cellEasy.Value
Set varFindScenario = .Rows(5).Find(What:=cellEasy, LookIn:=xlFormulas, LookAt:=xlWhole)


If Not varFindRequirement Is Nothing Then
lngFindRequirement = varFindRequirement.Row
If Not varFindScenario Is Nothing Then
lngFindScenario = varFindScenario.Column
'Modify thse column number boundaries as needed.
If lngFindRequirement >= 6 And lngFindRequirement <= 19 Then
If lngFindScenario >= 9 And lngFindScenario <= 16 Then

If varFindScenario.Column And cells(cellEstelle.Row, 2).Value = "Pass" Then
strPassFail = "+"
Else
strPassFail = "-"
End If

For lngFindScenario = 9 To 16
If Len(.cells(lngFindRequirement, lngFindScenario).Value) = 0 And .cells(lngFindRequirement, lngFindScenario).Interior.ColorIndex = -4142 Then .cells(lngFindRequirement, lngFindScenario).Value = strPassFail
Next lngFindScenario
End If
End If
End If
End If

Next cellEasy

Next cellEstelle

End With

Set varFindRequirement = Nothing
Application.ScreenUpdating = True
MsgBox "Completed.", , "Done."

End Sub


This is what the code above is giving me:

Test Tracking Test2 adding new section.xlsm
HIJKLMNOP
5Abort_12Cold_Cut_2Hot_Cut_1Hot_Cut_3Omega_1Pharos_1Hot_Cut_2Cold_Cut_1
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
Sheet3


From this data:
Test Tracking Test2 adding new section.xlsm
ABC
1SPS#ResultScenarios
2D_ANT_SFTY_01PassAbort_12
3D_ANT_SFTY_03FailHot_Cut_3
4BITO_1011PassPharos_1
5BITO_1012PassCold_Cut_1
6QNTI_01FailHot_Cut_1
7QNTI_02Pass
8PLT_555Pass
9PLT_556Pass
Sheet4
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C2:C5Cell ValueduplicatestextNO
C8Cell ValueduplicatestextNO
 
Perfect Thank you very much now I am going to try it on a really big data set and see how it does do you forsee any hiccups?
 
Upvote 0

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Perfect Thank you very much now I am going to try it on a really big data set and see how it does do you forsee any hiccups?
It's not optimized for speed. You may expect app freeze.
 
Upvote 0
To clarify my repeated requests for what Sheet3 was like before and after the code is run. That was to determine for sure whether the code was producing the text values in row 5 and/or the text values in column H and/or the yellow in the various cells, or whether some or all of those things were already there. Remember that you are very familiar with your workbook but we are not, and only have what you tell us or show us.

If you have large data, I think a considerably faster code can be provided but again I would like some clarification.
In all of your mini-sheets of Sheet3, the yellow cells contain no values, just colour. Is that actually the case with your real Sheet3? In other words, in developing any code, can I be sure that those yellow cells contain nothing but colour?
 
Upvote 0
To clarify my repeated requests for what Sheet3 was like before and after the code is run. That was to determine for sure whether the code was producing the text values in row 5 and/or the text values in column H and/or the yellow in the various cells, or whether some or all of those things were already there. Remember that you are very familiar with your workbook but we are not, and only have what you tell us or show us.

If you have large data, I think a considerably faster code can be provided but again I would like some clarification.
In all of your mini-sheets of Sheet3, the yellow cells contain no values, just colour. Is that actually the case with your real Sheet3? In other words, in developing any code, can I be sure that those yellow cells contain nothing but colour?
Since i studied the code, I will try to answer.
The code does not put the text in row 5 and col 8.
It's already there. The code use these texts to locate the cell to put plus or minus.
Then if the cell has a value or a color in it - it's skipped.
The yellow also seems to be there, although I can't imagine someone will fill a large range with scattered yellow cells manually.
I still can't completely understand the idea behind this exercise.
It also seems that the scenario column is separate from the first two.
 
Upvote 0
Then if the cell has a value or a color in it - it's skipped.
Again, good reason to have before/after mini-sheets rather than trying to deduce such information from (non-working) code. :)
Hopefully the OP can add more certainty/clarity here too.
 
Upvote 0

Forum statistics

Threads
1,214,583
Messages
6,120,383
Members
448,955
Latest member
BatCoder

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