Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Dos validaciones con Private Sub Worksheet_Change(ByVal Target As Range)

28 views
Skip to first unread message

Jonathan Saul

unread,
Oct 21, 2021, 2:08:26 PM10/21/21
to
Buena tarde,

Necesito validar dos rangos de celdas con esta misma macro me ayudan!!!!!

Ejemplo:
Private Sub Worksheet_Change(ByVal Target As Range)

'<<<< CENTRO DE TRABAJO CON RANGO>>>>
If Not Intersect(Target, Range("K11:K50")) Is Nothing Then

Dim Celda2 As Range

For Each Celda2 In Range("K$11:$K$50")

'SI NO ES NUMERO / SI ES MAYOR A 10 DIGITOS / SI NO INICIA CON UNO (1)


If Celda2 = Empty Then
GoTo Siguiente
End If


If IsNumeric(Celda2) = False Or Len(Celda2) > 10 Or Mid(Celda2, 1, 1) <> "1" Then

Celda2.Value = Empty 'Entonces que borre el contenido de la celda
MsgBox "Centro de Trabajo Incorrecto"
ActiveCell.Offset(-1, 0).Select 'Vuelve a la celda para editarla

End If

Siguiente:
Next Celda2

End If

End Sub

esto lo hace con las columna "K" pero en la misma hoja quiero que también lo haga en la columna "AB"
0 new messages