Códigos para aplicar condiciones en columnas
Siento molestarte otra vez, para el mismo tema.
¿Cómo puedo hacer para que estas condiciones que hemos aplicado en la columna A y B se cumpla en las siguientes columnas(H:I, J:K, L:M, N:0)pero empezando por la fila 7?.
Te envío el último código que me enviaste.
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Column = 1 Then
'caso que no haya nada
If Target = "" Then
Target.Offset(0, 1).Select
Selection.ClearContents
Selection.Font.ColorIndex = 10
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="X"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = "Mensaje Input1"
.ErrorMessage = "Mensaje de error1"
.ShowInput = True
.ShowError = True
End With
'caso que se haya escrito un numero
ElseIf IsNumeric(Target) Then
Target.Offset(0, 1).Select
Selection.ClearContents
Selection.Font.ColorIndex = 0
With Selection.Validation
.Delete
.Add Type:=xlValidateWholeNumber, AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, Formula1:="-100000", Formula2:="100000"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = "Mensaje Input2"
.ErrorMessage = "Mensaje de error2"
.ShowInput = True
.ShowError = True
End With
'caso que se haya escrito una X
ElseIf Target = "X" Or Target = "x" Then
Target.Offset(0, 1).Select
Selection.ClearContents
Selection.Font.ColorIndex = 0
With Selection.Validation
.Delete
'en las celdas K1 y K2 tiene que estar escrito SI y NO, puedes ponerlo de color blanco para que no se vea
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=$K$1:$K$2"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = "Mensaje Input3"
.ErrorMessage = "Mensaje de error3"
.ShowInput = True
.ShowError = True
End With
End If
End If
End Sub
Gracias de nuevo.
¿Cómo puedo hacer para que estas condiciones que hemos aplicado en la columna A y B se cumpla en las siguientes columnas(H:I, J:K, L:M, N:0)pero empezando por la fila 7?.
Te envío el último código que me enviaste.
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Column = 1 Then
'caso que no haya nada
If Target = "" Then
Target.Offset(0, 1).Select
Selection.ClearContents
Selection.Font.ColorIndex = 10
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="X"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = "Mensaje Input1"
.ErrorMessage = "Mensaje de error1"
.ShowInput = True
.ShowError = True
End With
'caso que se haya escrito un numero
ElseIf IsNumeric(Target) Then
Target.Offset(0, 1).Select
Selection.ClearContents
Selection.Font.ColorIndex = 0
With Selection.Validation
.Delete
.Add Type:=xlValidateWholeNumber, AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, Formula1:="-100000", Formula2:="100000"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = "Mensaje Input2"
.ErrorMessage = "Mensaje de error2"
.ShowInput = True
.ShowError = True
End With
'caso que se haya escrito una X
ElseIf Target = "X" Or Target = "x" Then
Target.Offset(0, 1).Select
Selection.ClearContents
Selection.Font.ColorIndex = 0
With Selection.Validation
.Delete
'en las celdas K1 y K2 tiene que estar escrito SI y NO, puedes ponerlo de color blanco para que no se vea
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=$K$1:$K$2"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = "Mensaje Input3"
.ErrorMessage = "Mensaje de error3"
.ShowInput = True
.ShowError = True
End With
End If
End If
End Sub
Gracias de nuevo.
1 Respuesta
Respuesta de t4373125
1