Comparar valores únicos entre dos columnas

La primera macros compara valores únicos de la columna A con la columna B y me muestra los valores únicos de la columna A en la columna C.

En la segunda macros quisiera que me compare los valores únicos de la columna B con la columna A y que me muestre los valores únicos de la columna B en la columna E.

El problema es que si activo los dos al mismo tiempo solo se me activa la segunda macro y no las dos al mismo tiempo. Les agradecería si me ayudaran

Sub comparar1_enter()
Application.ScreenUpdating = False 'VALORES ÚNICOS DE LA COLUMNA A
'http://www.todoexpertos.com/categorías/tecnología-e-internet/software-y-aplicaciones/microsoft-excel/respuestas/2143093/hacer-una-macro-para-conparar-2-columnas-en-excel
Dim celda, valor As String
Columns("C").ClearContents
Range("A2").Select
Do While ActiveCell.Value <> ""
celda = ActiveCell.Address
valor = ActiveCell.Value
Range("B2").Select
Do While ActiveCell.Value <> ""
If ActiveCell.Value = valor Then
Exit Do
Range(celda).Select
End If
ActiveCell.Offset(1, 0).Select
Loop
If ActiveCell.Value = "" Then
Range("C2").Select
Do While ActiveCell.Value <> ""
ActiveCell.Offset(1, 0).Select
Loop
ActiveCell.Value = valor
End If
Range(celda).Select
ActiveCell.Offset(1, 0).Select
valor = ActiveCell.Value
Application.ScreenUpdating = True
Loop
End Sub

__________________________________________________________________
Sub comparar2_enter()
Application.ScreenUpdating = False 'VALORES ÚNICOS DE LA COLUMNA B
'http://www.todoexpertos.com/categorías/tecnología-e-internet/software-y-aplicaciones/microsoft-excel/respuestas/2143093/hacer-una-macro-para-conparar-2-columnas-en-excel
Dim celda, valor As String
Columns("e").ClearContents
Range("b2").Select
Do While ActiveCell.Value <> ""
celda = ActiveCell.Address
valor = ActiveCell.Value
Range("a2").Select
Do While ActiveCell.Value <> ""
If ActiveCell.Value = valor Then
Exit Do
Range(celda).Select
End If
ActiveCell.Offset(1, 0).Select
Loop
If ActiveCell.Value = "" Then
Range("e2").Select
Do While ActiveCell.Value <> ""
ActiveCell.Offset(1, 0).Select
Loop
ActiveCell.Value = valor
End If
Range(celda).Select
ActiveCell.Offset(1, 0).Select
valor = ActiveCell.Value
Application.ScreenUpdating = True
Loop
End Sub

1 respuesta

Respuesta
1

¿Qué significa: '... si activo los dos al mismo tiempo...'?

Si tenés un botón o una instrucción de llamada, tenés que llamar a las 2, 1 x vez:

Ej:

Sub llamada()

Call comparar1_enter

Call comparar2_enter

Esa parte de call yo lo sé manejar, puedo incluir un call en el botón de la macro comparar1, pero el problema es sólo me va a dar valores únicos de una de las dos macros ya sea la macro comparar1 o la macro comparar2.

No sé si abra otra forma en lugar de utilizar ActiveCell.

LE AGRADECERÍA A MONTONES SI ME AYUDARAS EN ESA PARTE

Sub comparar1_enter()
Application.ScreenUpdating = False 'VALORES ÚNICOS DE LA COLUMNA A
Dim celda, valor As String
Columns("C").ClearContents
Range("A2").Select
Do While ActiveCell.Value <> ""
celda = ActiveCell.Address
valor = ActiveCell.Value
Range("B2").Select
Do While ActiveCell.Value <> ""
If ActiveCell.Value = valor Then
Exit Do
Range(celda).Select
End If
ActiveCell.Offset(1, 0).Select
Loop
If ActiveCell.Value = "" Then
Range("C2").Select
Do While ActiveCell.Value <> ""
ActiveCell.Offset(1, 0).Select
Loop
ActiveCell.Value = valor
End If
Range(celda).Select
ActiveCell.Offset(1, 0).Select
valor = ActiveCell.Value
Application.ScreenUpdating = True
Loop
End Sub

__________________________________________________________________

Enviado.

Sdos

Elsa

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas