Está en la página 1de 8

Buscar textos

Sub prueba()

Dim hj As Worksheet

Dim contExiste As Integer

Dim busqueda As Range

Dim res, consulta As String

Dim aa As String

Dim maquina As String

Dim numorden, FECHA As String

Dim causaraiz As String

Dim tiempo As String

Dim responsable As String

Dim JUAN As Integer


Dim ultimaFila As Long

Dim ultimaFilaAuxiliar As Long

Dim cont As Long

Dim palabraBusqueda As String

palabraBusqueda = Sheets("Hoja5").Cells(2, 12)

palabraBusqueda = "*" & palabraBusqueda & "*"

ultimaFila = Sheets("Hoja1").Range("F" &


Rows.Count).End(xlUp).Row

If ultimaFila < 2 Then

Exit Sub

End If

JUAN = "3"

res = ""

consulta = Sheets("hoja5").Cells(2, 12)

If consulta = "" Then

Exit Sub

End If
'If consulta = "j" Then

'Else

'JUAN = "2"

'End If

Select Case consulta

Case "j"

JUAN = "7"

Case "fin_forming"

Case "EDU"

JUAN = "7"

Case "audi"

Case "May"

JUAN = "2"

End Select

For Each hj In ThisWorkbook.Worksheets

With hj.UsedRange

Set busqueda = .Cells.Find(what:=consulta)

If Not busqueda Is Nothing Then


If hj.Name <> "Hoja5" Then

ultimaFila = hj.Range("C" & Rows.Count).End(xlUp).Row

If ultimaFila < 2 Then

Exit Sub

End If

For cont = 2 To ultimaFila

If hj.Cells(cont, JUAN) Like palabraBusqueda Then

FECHA = hj.Cells(cont, 2)

maquina = hj.Cells(cont, 3)

numorden = hj.Cells(cont, 4)

causaraiz = hj.Cells(cont, 5)

tiempo = hj.Cells(cont, 6)

responsable = hj.Cells(cont, 7)
ultimaFilaAuxiliar = Sheets("Hoja5").Range("C" &
Rows.Count).End(xlUp).Row

Sheets("Hoja5").Cells(ultimaFilaAuxiliar + 1, 2) = FECHA

Sheets("Hoja5").Cells(ultimaFilaAuxiliar + 1, 3) = maquina

Sheets("Hoja5").Cells(ultimaFilaAuxiliar + 1, 4) = numorden

Sheets("Hoja5").Cells(ultimaFilaAuxiliar + 1, 5) = causaraiz

Sheets("Hoja5").Cells(ultimaFilaAuxiliar + 1, 6) = tiempo

Sheets("Hoja5").Cells(ultimaFilaAuxiliar + 1, 7) = responsable

End If

Next

res = res & vbCrLf & hj.Name

contExiste = 1

Set busqueda = .FindNext(busqueda)

End If

End If

End With

Next

If contExiste = 0 Then

MsgBox ("dato no existe")

MsgBox JUAN

Else
res = "dato encontrado en las hojas" & vbCrLf & res

MsgBox res

MsgBox JUAN

End If

End Sub
Graficas auto

Sub Macro7()

'

' Macro7 Macro

'

'

rango = Sheets("Hoja5").Range("C2").End(xlDown).Row

rango1 = Sheets("Hoja5").Range("F2").End(xlDown).Row

' ActiveSheet.Shapes.AddChart2(286,
xl3DColumnClustered).Select

'ActiveChart.SetSourceData Source:=Range("Hoja5!C2:f" &


rango)

'Range("J26").Select

Range("C1:F" & rango1).Select

ActiveSheet.Shapes.AddChart2(201,
xlColumnClustered).Select

ActiveChart.SetSourceData Source:=Range("Hoja5!$C$1:$F$"
& rango1)

Range("H2").Select
Borrar datos

Sub Macro1()

'

' Macro1 Macro

rango = Sheets("Hoja5").Range("F2").End(xlDown).Row

'

Range("Hoja5!B2:G" & rango).Select

Selection.ClearContents

Range("G2").Select

End Sub

End Sub

También podría gustarte