Modificar el código para aplicar las condiciones a toda una columna, no sólo a una celda en Excel
¿Qué tendría que modificar del código que me enviastes para que las condiciones se aplicaran a toda la columna (no únicamente a a la celda A1)? Gracias de nuevo.
Prueba este codigo, a ver si funciona: 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 = "" .ErrorMessage = "" .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 = "" .ErrorMessage = "" .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 = "" .ErrorMessage = "" .ShowInput = True .ShowError = True End With End If End If End Sub Si algo va mal me lo dices, porque no lo he probado. Ah!, la proxima vez vuelve a ponerme el código antiguo, así no lo tengo que buscar.