Bucle en visual para excel

Osasa54

New Member
Joined
Sep 10, 2002
Messages
31
Hola!

Por medio de visual de excel quiero hacer un bucle para que me busque el valor de una variable declarada en un rango de celdas:
Ej. (os pongo el código):

Sub Macro1

Dim centro As String
centro = InputBox("Nombre del Centro", "", "Toma de datos de Centro")

Dim j As Integer

For j = 2 to 200

If centro = ActiveSheet.Cells(j, 1).Value Then
MsgBox "OK"
Exit For
End If
Next
End sub

Esto me funciona correctamente, es decir, si en cualquier celda del rango a2:a200 escribo "prueba", y al ejecutar la macro, cuando me pide el valor del inputbox escribo "prueba", me devuelve "ok". pero el problema es que quiero buscar el valor de la variable centro en una hoja distinta a la que tengo activada. La hoja donde quiero buscar se llama "datos".

Esposible hacer esto en excel?

Regards
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

Forum statistics

Threads
1,215,092
Messages
6,123,064
Members
449,090
Latest member
fragment

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