realizar el mismo procedimiento en los demas cuadros

dragonfire33

Board Regular
Joined
Oct 7, 2021
Messages
90
Office Version
  1. 365
Platform
  1. Windows
como puedo modificar este codigo para que la busqueda que realiza en el primer cuadro , me arroje el 2do y tercer dato mas repetido de acuerdo a la coincidencia a buscar
VBA Code:
Option Explicit
Private Sub CommandButton8_Click()
    Dim R As Range
Dim T As String
Dim C As String
Set R = Sheets("hoja1").Range("Z1:TW42") 'cambiar ahoja activa
If Me.Uno.Text = "" Then T = T & "?" Else T = T & Uno.Text
If Me.Dos.Text = "" Then T = T & "?" Else T = T & Dos.Text
If Me.Tres.Text = "" Then T = T & "?" Else T = T & Tres.Text
If Me.Cuatro.Text = "" Then T = T & "?" Else T = T & Cuatro.Text
Call seleccionaceldascoincidentes(T, R)
End Sub

Sub seleccionaceldascoincidentes(texto As String, rango As Range)
Dim x As Long, y As Integer
Dim Fila As Long, Veces As Long
Me.ListBox1.Clear
Vecesx = 0
For x = 1 To 42
   Fila = x
   Veces = 0
   For y = Range("Z1").Column To Range("TW1").Column
      If Cells(x, y).Value Like texto Then
        Me.ListBox1.AddItem Cells(x, y).Address & " : " & Cells(x, y).Value
        Veces = Veces + 1
      End If
   Next
   If Veces > CLng(Vecesx) Then
      Filax = x
      Vecesx = Veces
   End If
  
Next

End Sub



Private Sub UserForm_Click()

End Sub
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Buenas, cambia la linea de busqueda por esta .
VBA Code:
If Cells(x, y).Value Like texto Or Cells(x, y).Value = Replace(texto, "?", "") Then
le añadimos la opcion de comparar el texto buscado con el encontrado sin la interrogación.

suerte
 
Upvote 0

Forum statistics

Threads
1,224,862
Messages
6,181,458
Members
453,042
Latest member
AbdelrahmanExcel

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