dimanche 1 décembre 2019

If Else Then with multiple conditions not working

I'm current trying to implement this logic into my sub-procedure. There are 3 conditions and 4 outcomes as listed below:

enter image description here

The values in Col I as shown in the attached picture is driven by a data validation list in the master worksheet

I tried using the following code to reflect the above logic:

If DataImport.Cells(i, "E").Value <> 0 And DataImport.Cells(i, "F").Value <> 0 And DataImport.Cells(i, "I").Value = "Hide" Then
ThisWorkbook.Worksheets(ws(index)).Visible = False
ElseIf DataImport.Cells(i, "E").Value = 0 And DataImport.Cells(i, "F").Value = 0 And DataImport.Cells(i, "I").Value = "Hide" Then
ThisWorkbook.Worksheets(ws(index)).Visible = False
ElseIf DataImport.Cells(i, "E").Value <> 0 And DataImport.Cells(i, "F").Value <> 0 And DataImport.Cells(i, "I").Value = "Unhide" Then
ThisWorkbook.Worksheets(ws(index)).Visible = True
ElseIf DataImport.Cells(i, "E").Value = 0 And DataImport.Cells(i, "F").Value = 0 And DataImport.Cells(i, "I").Value = "Unhide" Then
ThisWorkbook.Worksheets(ws(index)).Visible = False

I'm not sure if I've implemented this correctly, as the procedure is ignoring my 3rd condition and it is still showing related worksheets with "Hidden" in Column I.

Aucun commentaire:

Enregistrer un commentaire