Encontrar un rango dentro de Otro!!

yeye

New Member
Joined
Jul 18, 2002
Messages
32
Como puedo saber si la persona hizo un cambio en un rango que está dentro de un rango que he definido,
Por ejemplo:

MI AREA DE TRABAJO EL Rango1="A1:D5"

si se realiza un cambio en el rango2="z2", entonces no haría nada, pero si se realiza un cambio en rango2="A3" entonces hago algunos procedimientos


Gracias por su colaboracion!!!
This message was edited by yeye on 2002-08-02 16:55
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Si lo que quieres es saber cuando se modifica una celda, usa el evento Change de la hoja en cuestión, el siguiente codigo te muestra un mensaje, SOLO cuando la celda A3 ha sido modificada y en combinacion con el evento SelectionChange se puede dar la opcion de cancelar o regresar al valor anterior...<pre><font face="Courier New" size=2><font color = #000080>Option</font><font color = #000080>Explicit</font><font color = #000080>Dim</font> strValor<font color = #000080>As</font><font color = #000080>String</font><font color = #008000>'Este evento se produce cuando el usuario cambia una celda</font><font color = #000080>Private</font><font color = #000080>Sub</font> Worksheet_Change(<font color = #000080>ByVal</font> Target<font color = #000080>As</font> Range)<font color = #000080>Dim</font> Res<font color = #000080>As</font><font color = #000080>Integer</font><font color = #008000> 'Verificamos que celda se modifico</font><font color = #000080>If</font> Target.Address(<font color = #000080>False</font>,<font color = #000080>False</font>) = "A3"<font color = #000080>Then</font><font color = #008000> 'Informamos del cambio</font>
Res = MsgBox("La celda A3 ha sido modificada" & _
vbCrLf & vbCrLf & _
"Valor anterior = " & strValor & _
vbCrLf & _
"Valor actual = " & Target.Value & _
vbCrLf & vbCrLf & _
"¿Aceptas el cambio?", vbYesNo, "Confirmar")<font color = #000080>If</font> Res = vbNo<font color = #000080>Then</font><font color = #008000> 'Si responde que no, regresamos al valor anterior, es</font><font color = #008000> 'algo similar a cuando el usuario presiona Cancelar</font><font color = #008000> 'solo que aqui lo controlamos nosotros</font>
Application.EnableEvents =<font color = #000080>False</font>
Target.Value = strValor
Application.EnableEvents =<font color = #000080>True</font>
strValor = vbNullString<font color = #000080>Else</font>
strValor = Target.Value<font color = #000080>End</font><font color = #000080>If</font><font color = #000080>End</font><font color = #000080>If</font><font color = #000080>End</font><font color = #000080>Sub</font><font color = #008000>'Este evento se produce cuando el usuario cambia la seleccion</font><font color = #000080>Private</font><font color = #000080>Sub</font> Worksheet_SelectionChange(<font color = #000080>ByVal</font> Target<font color = #000080>As</font> Range)<font color = #008000> 'Verificamos que celda se selecciono</font><font color = #000080>If</font> Target.Address(<font color = #000080>False</font>,<font color = #000080>False</font>) = "A3"<font color = #000080>Then</font><font color = #008000> 'Si fue la celda A3 guardamos el valor actual</font>
strValor = Target.Value<font color = #000080>End</font><font color = #000080>If</font><font color = #000080>End</font><font color = #000080>Sub</font></font></pre>

_________________
TODO LO QUE NO ES DADO ES PERDIDO
This message was edited by valedor on 2002-08-02 21:44
 
Upvote 0
Yo lo haria asi:

Imaginamos que nuestro rango es: B3:C5

Entonces:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row > 2 And Target.Row < 6 And Target.Column > 1 And Target.Column < 4 Then
MsgBox "Has modificado dentro del rango"
End If

End Sub
 
Upvote 0

Forum statistics

Threads
1,217,370
Messages
6,136,155
Members
449,995
Latest member
rport

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