Cargando

valores dependientes con vba




Pulsa corazón para recibir avisos de nuevas Respuestas

  AUTOR PREGUNTA

Publicado 08 mayo 2014 - 23:20
tengo un excel donde tengo dos columnas A1 y A2, donde las respuestas que pueden contener cada una son Si o No, pero, si en una sección la primera respuesta es Si la siguiente debe ser No y viceversa. ¿Cómo podría hacer esto con VBA?
  • ¿Tienes la misma pregunta? Yo también
  • Volver arriba

 

Publicado 09 mayo 2014 - 02:17
Coloca el siguiente código en tu evento Worksheet_Change:


Const col1pos= 1
Const col2pos= 2
Application.EnableEvents = False Select Case Target.Column
Case col1pos
If UCase(Target.Value) = "S" Then
ActiveSheet.Cells(Target.Row, col1pos) = "S"
ActiveSheet.Cells(Target.Row, col2pos) = "N"
Else
ActiveSheet.Cells(Target.Row, col1pos) = "N"
ActiveSheet.Cells(Target.Row, col2pos) = "S"
End If
Case col2pos
If UCase(Target.Value) = "S" Then
ActiveSheet.Cells(Target.Row, col1pos) = "N"
ActiveSheet.Cells(Target.Row, col2pos) = "S"
Else
ActiveSheet.Cells(Target.Row, col1pos) = "S"
ActiveSheet.Cells(Target.Row, col2pos) = "N"
End If
End Select
Application.EnableEvents = True


   AUTOR PREGUNTA

Publicado 09 mayo 2014 - 04:48
Gracias Jhony, muy bueno tu ejemplo


X