Agregar un línea de división al código

Pregunta para dante agregar una line de división para todos los fines de ano o sea todos los diciembres gracias

1 respuesta

Respuesta
1

La línea será insertada cada vez que se actualice el mes de diciembre, eso será con cada diciembre de cada año

Private Sub Worksheet_Change(ByVal Target As Range)
'Por.Dante Amor
    If Not Intersect(Target, Range("B:E")) Is Nothing Then
        If Target.Count > 1 Then Exit Sub
        If Target.Row < 4 Then Exit Sub
        If Cells(Target.Row, "A") = "" Then
            MsgBox "No hay fecha"
            Exit Sub
        End If
        '
        mes = Format(Cells(Target.Row, "A"), "mmm")
        año = Year(Cells(Target.Row, "A"))
        fecha = mes & "-" & año
        Set b = Columns("G").Find(fecha, lookat:=xlWhole)
        If Not b Is Nothing Then
            f = b.Row
        Else
            f = Range("G" & Rows.Count).End(xlUp).Row + 1
            If f < 4 Then f = 4
        End If
        Cells(f, "G") = "'" & fecha
        c = Target.Column + 6
        Cells(f, c) = Cells(f, c) + Target.Value
        Cells(f, c).NumberFormat = "$* #,##0;[Red]$ * -#,##0"
        Cells(f, "K") = Cells(f, "K") + Target.Value
        Cells(f, "K").Interior.Color = 49407
        With Range(Cells(f, "G"), Cells(f, "K")).Borders(xlEdgeBottom)
            If mes = "Dic" Then
                .LineStyle = xlContinuous
                .ColorIndex = 0
                .TintAndShade = 0
                .Weight = xlThin
            Else
                .LineStyle = xlNone
            End If
        End With
    End If
End Sub

Saludos.Dante Amor

Dante la estoy probando y cuando llego a dic no se pone la línea

Prueba con esta:

Private Sub Worksheet_Change(ByVal Target As Range)
'Por.Dante Amor
    If Not Intersect(Target, Range("B:E")) Is Nothing Then
        If Target.Count > 1 Then Exit Sub
        If Target.Row < 4 Then Exit Sub
        If Cells(Target.Row, "A") = "" Then
            MsgBox "No hay fecha"
            Exit Sub
        End If
        '
        mes = Format(Cells(Target.Row, "A"), "mmm")
        año = Year(Cells(Target.Row, "A"))
        fecha = mes & "-" & año
        Set b = Columns("G").Find(fecha, lookat:=xlWhole)
        If Not b Is Nothing Then
            f = b.Row
        Else
            f = Range("G" & Rows.Count).End(xlUp).Row + 1
            If f < 4 Then f = 4
        End If
        Cells(f, "G") = "'" & fecha
        c = Target.Column + 6
        Cells(f, c) = Cells(f, c) + Target.Value
        Cells(f, c).NumberFormat = "$* #,##0;[Red]$ * -#,##0"
        Cells(f, "K") = Cells(f, "K") + Target.Value
        Cells(f, "K").Interior.Color = 49407
        With Range(Cells(f, "G"), Cells(f, "K")).Borders(xlEdgeBottom)
            If UCase(mes) = "DIC" Then
                .LineStyle = xlContinuous
                .ColorIndex = 0
                .TintAndShade = 0
                .Weight = xlThin
            Else
                .LineStyle = xlNone
            End If
        End With
    End If
End Sub

Recuerda valorar las preguntas pendientes

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas