garden_rael
Board Regular
- Joined
- Apr 1, 2008
- Messages
- 100
I'm trying to create a button to fill a simple form made in Excel
It should prompt the user for the account number... and then look for it in a database located in a hidden sheet in the book... if it finds it... it will put the found number on a cell and easy vlookups do the rest...
But the searching macro is driving me nuts!
This is what I have so far...
Sub TURNO()
Dim cto As String
Dim esta As String
Dim neta As Boolean
cto = InputBox("Busqueda de Contrato", "Generación de Turnos")
Application.ScreenUpdating = False
Sheets("Lista").Activate
Range("A1:A10000").Activate
If neta = IsEmpty(Cells.Find(What:=cto, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)) Then
Cells.Find(What:=cto, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
esta = ActiveCell.Value
Sheets("TURNO").Activate
Cells(1, 9).Value = esta
GoTo Final
Else
Sheets("Lista").Activate
a = MsgBox("Contrato no encontrado, verifique...")
Final:
End If
Application.ScreenUpdating = True
End Sub
It should prompt the user for the account number... and then look for it in a database located in a hidden sheet in the book... if it finds it... it will put the found number on a cell and easy vlookups do the rest...
But the searching macro is driving me nuts!

This is what I have so far...
Sub TURNO()
Dim cto As String
Dim esta As String
Dim neta As Boolean
cto = InputBox("Busqueda de Contrato", "Generación de Turnos")
Application.ScreenUpdating = False
Sheets("Lista").Activate
Range("A1:A10000").Activate
If neta = IsEmpty(Cells.Find(What:=cto, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)) Then
Cells.Find(What:=cto, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
esta = ActiveCell.Value
Sheets("TURNO").Activate
Cells(1, 9).Value = esta
GoTo Final
Else
Sheets("Lista").Activate
a = MsgBox("Contrato no encontrado, verifique...")
Final:
End If
Application.ScreenUpdating = True
End Sub