how do I make this userform comply with these conditions in vba

0

I have this code of the form that according to the data that is placed in the columns "ba: bd" of all the sheets, analyzes them and looks for a repeated number among the four sheets but the detail is that if the number is repeated more than once in a single sheet I throw that data and what I want is that the number is in the four pages of the book fulfilling two coincidences between its two initial figures this is the code

Option Explicit
Option Base 1
Option Compare Text
Sub FORM()
   UserForm1.Show
End Sub


Sub RESOLVER()

'UserForm1.Show

Dim Z As Object, s$, x$
Dim A: A = Array("pista", "avanzada", "piramide", "resultados")
Dim it, yt, hojas%
Dim R As Range, fr&, q&
Dim t As Range, xt As Range, xct%
Dim tu As Range


Set Z = CreateObject("Scripting.Dictionary")

For Each it In A
   hojas = hojas + 1
   Set t = Sheets(it).Range("BA:BX"): Call QUITAR·COLOR(t)
   q = Application.WorksheetFunction.CountA(Sheets(it).Range("BF:BF"))
   Set R = Sheets(it).Range("BF1:BF" & q)
   For fr = 1 To R.Rows.Count
      s = R(fr, 1)
      If InStr(1, s, "X") > 0 Then
      '----
      Else
      
         If Z.EXISTS(s) Then
            Z(s) = Z(s) + 1
         Else
            Z.Add s, 1
         End If
      
      End If
   
   Next


   For Each yt In Z
      If Z(yt) <> hojas Then
         Z.Remove yt
      End If
   Next
    
Next


With UserForm1
For it = 1 To 4
For yt = 1 To 4
   s = Sheets(A(it)).Range("BF1")
   .Controls("TB" & it & yt) = Mid(s, yt, 1)
Next
Next


For Each it In Z
   .TB1 = it
   .TB2 = it
   .TB3 = it
   .TB4 = it
   If Z.Count > 1 Then Exit For
Next
End With

For Each it In A
   For Each xt In Sheets(it).Range("BF:BH")
      If xt = UserForm1.TB1 Then
         Set t = Sheets(it).Range(xt.Address)
            For xct = -5 To 5
               Set tu = t.Offset(, xct)
               If Len(Trim(tu)) > 0 Then
                  Call PONER·COLOR(tu)
                  Set tu = Nothing
               End If
            Next
         Exit For
      End If
   Next
Next

UserForm1.Repaint
   
End Sub

Sub QUITAR·COLOR(t)

    With t.Interior
        .Pattern = xlNone
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With

End Sub

Sub PONER·COLOR(t)
    With t.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 65535
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
End Sub

    
asked by Jhon Fredy Murcia Rodriguez 11.04.2018 в 19:31
source

0 answers