Macros! Buscar datos en otro libro y mostrarlo en un message box

RuthyHermosa

New Member
Joined
Jan 22, 2014
Messages
3
Hola a todos!!
Muy bien, les explico...
Tengo un archivo llamado "Expedientes" Aquí tengo un userform donde ingreso varios datos en los cuadros de texto, con un botón copio esos datos en el mismo libro en que trabajo y con otro botón, copio los datos en el libro "database". database está cerrado siempre, solo se abre, guarda los datos copiados y se cierra...

La situación es la siguiente... Agregué un nuevo cuadro de texto y un nuevo botón... Necesito que cuando haga clic en el botón nuevo, se abra el libro "database", busque el valor del cuadro de texto en todas las hojas, y cuando lo encuentre, que el valor de la celda de la izquierda me salga en un message box... Eso es posible? He intentado todas las formas que se me ocurren pero no he llegado a nada, tengo una especie de bloqueo mental, help me please!!
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Hola,

Claro que con Excel todo es possible ...

Pero, sin el codigo de tus macros, nadie puede ayudarte para modificar tu codigo ...

HTH
 
Upvote 0
Hola James!! Claro, aquí lo dejo:


Private Sub CommandButton1_Click()
Sheets("CARATULA").Activate
TextBox1.SetFocus
ActiveSheet.Cells(2, 16).Select
ActiveCell = TextBox1.Value
Range("B" & Cells.Rows.Count).End(xlUp).Offset(1).Select
ActiveCell = TextBox2.Value
ActiveCell.Offset(0, 2) = TextBox3.Value
ActiveCell.Offset(0, 4) = TextBox4.Value
ActiveCell.Offset(0, 7) = TextBox5.Value
TextBox1.SetFocus
End Sub
Private Sub CommandButton4_Click()
Unload Me
End Sub

Private Sub CommandButton2_Click()
Workbooks.Open FileName:="\\C:\Users\alicia\Desktop\database - PRUEBA.xlsx"
Sheets("DB").Activate
TextBox3.SetFocus
Range("A" & Cells.Rows.Count).End(xlUp).Offset(1).Select
ActiveCell = TextBox1.Value
ActiveCell.Offset(0, 1) = TextBox2.Value
ActiveCell.Offset(0, 2) = TextBox3.Value
ActiveCell.Offset(0, 3) = TextBox4.Value
ActiveCell.Offset(0, 4) = TextBox5.Value
TextBox1.SetFocus
ActiveWorkbook.Save
ActiveWorkbook.Close
End Sub

Muchísimas gracias, saludos!!
 
Upvote 0

Forum statistics

Threads
1,226,739
Messages
6,192,739
Members
453,755
Latest member
IQBS

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