Jump to content

bordear similitudes en libro excel


Recommended Posts

hasta ahora en avanzado en este codigo pero necesito que se ejecute en la hoja activa , he tratado con activesheets y no se ejecuta , alguna otra idea?

Sub resaltar()


Sheets("hoja2").Select
f1 = Asc(Range("AK2").Value)
f2 = Asc(Range("AK3").Value)
C1 = Range("AL2").Value
C2 = Range("AL3").Value


For J = 0 To 7 'numeros de columnas
Debug.Print "siguiente fila"
If J Mod 2 = 0 Then
Debug.Print "esta si la hago :" & J
    For i = 0 To 9 'numero de filas
         Debug.Print Range("A" & Chr(f1 + J) & C1 + i).Address & "  :  " & Range("A" & Chr(f1 + J) & C1 + i).Value
         Debug.Print Range("A" & Chr(f1 + J) & C2 + 9 - i).Address & ": " & Range("A" & Chr(f1 + J) & C2 + 9 - i).Value
             If Range("A" & Chr(f1 + J) & C1 + i).Value = Range("A" & Chr(f1 + J) & C2 + 9 - i).Value Then
                resaltarCelda (Sheets("hoja2").Range("A" & Chr(f1 + J) & C1 + i))
                resaltarCelda (Sheets("hoja2").Range("A" & Chr(f1 + J) & C2 + 9 - i))
                     End If
        Next i
    Else
    Debug.Print "esta no la hago :" & J
    End If
    Next J
    

   
 MsgBox "proceso terminado"
 
    
End Sub


    Sub resaltarCelda(r As Range)
    r.Select
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .TintAndShade = 0
        .Weight = xlMedium
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .TintAndShade = 0
        .Weight = xlMedium
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .TintAndShade = 0
        .Weight = xlMedium
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .TintAndShade = 0
        .Weight = xlMedium
    End With
    Selection.Borders(xlInsideVertical).LineStyle = xlNone
    Selection.Borders(xlInsideHorizontal).LineStyle = xlNone

    End Sub

 

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

Privacy Policy