Borders Darstellung
03.02.2021 18:33:13
anno
1. Problem: beim Einfuegen einer "leeren" Zeile eines Blattes in dasselbe Blatt mit ThisWorkbook.Worksheets(i).Rows(61).Copy
ThisWorkbook.Worksheets(i).Rows(i_Neu).Insert Shift:=xlDown
in einen anderen Zellbereich "verschwinden" die "ExcelOriginalen" GridLinien in der eingefuegten und in der nach unten verschobenen Zeile.
Dachte dann: "mach's selbst" und "testete" einige Varianten aus -> 2. Problem
Der Test bricht ab:
<img src="https://www.herber.de/bbs/user/143582.jpg" border="0">
<pre>Sub border3()
Dim i, i_Zl, i_Sp, i_Typ(1 To 3), j, i_TypF(1 To 3) As Integer
Dim s_Typ(1 To 3) As String
ThisWorkbook.Worksheets("Border3").Columns.Range("A:P").ColumnWidth = 10.71
ActiveSheet.Range("A1:P40").Borders.LineStyle = xlNone
ActiveSheet.Range("A1:P40").ClearContents
ActiveSheet.Range("A1:P40").Borders(xlDiagonalDown).LineStyle = xlNone
ActiveSheet.Range("A1:P40").Borders(xlDiagonalUp).LineStyle = xlNone
i_Typ(1) = 2 ' "xlThin"
i_Typ(2) = 1 ' "xlHairline"
i_Typ(3) = -4138 ' xlNone
s_Typ(1) = "xlThin"
s_Typ(2) = "xlHairline"
s_Typ(3) = "xlMedium"
i_TypF(1) = 15 ' HellGrau
i_TypF(2) = 24 ' HellLila
i_TypF(3) = 34 ' HellBlau
i_Zl = 8
i_Sp = 2
For j = 1 To 3 ' Farben
' xlLineStyleNone -4142 Keine Linie
' xlContinuous 1 Durchgehende Linie
For i = 1 To 3 ' LinienStaerke
ThisWorkbook.Worksheets("Border3").Columns(i_Sp - 1).ColumnWidth = 30
With ThisWorkbook.Worksheets("Border3").Range(ThisWorkbook.Worksheets("Border3").Cells(i_Zl, i_Sp), ThisWorkbook.Worksheets("Border3").Cells(i_Zl, i_Sp + 2)).Borders(xlDiagonalDown)
.LineStyle = xlLineStyleNone
' .LineStyle = xlContinuous ' <- beim 1. Durchlauf [ j=1; i=1 ] Fehler
' .ColorIndex = i_TypF(j) ' <- beim 7. Durchlauf [ j=3; i=1; wechsel von ColorIndex=24 auf ColorIndex=34 ] Fehler
' .Weight = i_Typ(i) ' <- beim 5. Durchlauf [ j=2; i=2; wechsel von xlThin auf xlHairline ] Fehler
End With
ThisWorkbook.Worksheets("Border3").Cells(i_Zl, i_Sp - 1).Value = "xlDiagonalDown " & s_Typ(i) & " F= " & i_TypF(j)
With ThisWorkbook.Worksheets("Border3").Range(ThisWorkbook.Worksheets("Border3").Cells(i_Zl + 1, i_Sp), ThisWorkbook.Worksheets("Border3").Cells(i_Zl + 1, i_Sp + 2)).Borders(xlDiagonalUp) '.Weight = i_Typ(i) ' xlThin
.LineStyle = xlLineStyleNone
' .LineStyle = xlContinuous ' <- beim 1. Durchlauf [ j=1; i=1 ] Fehler
' .ColorIndex = i_TypF(j) ' <- beim 7. Durchlauf [ j=3; i=1; wechsel von ColorIndex=24 auf ColorIndex=34 ] Fehler
' .Weight = i_Typ(i) ' <- beim 5. Durchlauf [ j=2; i=2; wechsel von xlThin auf xlHairline ] Fehler
End With
ThisWorkbook.Worksheets("Border3").Cells(i_Zl + 1, i_Sp - 1).Value = "xlDiagonalUp " & s_Typ(i) & " F= " & i_TypF(j)
With ThisWorkbook.Worksheets("Border3").Range(ThisWorkbook.Worksheets("Border3").Cells(i_Zl + 2, i_Sp), ThisWorkbook.Worksheets("Border3").Cells(i_Zl + 2, i_Sp + 2)).Borders(xlEdgeBottom) ' .Weight = i_Typ(i) ' xlThin
.LineStyle = xlLineStyleNone
' .LineStyle = xlContinuous ' <- beim 1. Durchlauf [ j=1; i=1 ] Fehler
' .ColorIndex = i_TypF(j) ' <- beim 7. Durchlauf [ j=3; i=1; wechsel von ColorIndex=24 auf ColorIndex=34 ] Fehler
' .Weight = i_Typ(i) ' <- beim 5. Durchlauf [ j=2; i=2; wechsel von xlThin auf xlHairline ] Fehler
End With
ThisWorkbook.Worksheets("Border3").Cells(i_Zl + 2, i_Sp - 1).Value = "xlEdgeBottom " & s_Typ(i) & " F= " & i_TypF(j)
With ThisWorkbook.Worksheets("Border3").Range(ThisWorkbook.Worksheets("Border3").Cells(i_Zl + 3, i_Sp), ThisWorkbook.Worksheets("Border3").Cells(i_Zl + 3, i_Sp + 2)).Borders(xlEdgeLeft) ' .Weight = i_Typ(i) ' xlThin
.LineStyle = xlLineStyleNone
' .LineStyle = xlContinuous ' <- beim 1. Durchlauf [ j=1; i=1 ] Fehler
' .ColorIndex = i_TypF(j) ' <- beim 7. Durchlauf [ j=3; i=1; wechsel von ColorIndex=24 auf ColorIndex=34 ] Fehler
' .Weight = i_Typ(i) ' <- beim 5. Durchlauf [ j=2; i=2; wechsel von xlThin auf xlHairline ] Fehler
End With
ThisWorkbook.Worksheets("Border3").Cells(i_Zl + 3, i_Sp - 1).Value = "xlEdgeLeft " & s_Typ(i) & " F= " & i_TypF(j)
With ThisWorkbook.Worksheets("Border3").Range(ThisWorkbook.Worksheets("Border3").Cells(i_Zl + 4, i_Sp), ThisWorkbook.Worksheets("Border3").Cells(i_Zl + 4, i_Sp + 2)).Borders(xlEdgeRight) '.Weight = i_Typ(i) ' xlThin
.LineStyle = xlLineStyleNone
' .LineStyle = xlContinuous ' <- beim 1. Durchlauf [ j=1; i=1 ] Fehler
' .ColorIndex = i_TypF(j) ' <- beim 7. Durchlauf [ j=3; i=1; wechsel von ColorIndex=24 auf ColorIndex=34 ] Fehler
' .Weight = i_Typ(i) ' <- beim 5. Durchlauf [ j=2; i=2; wechsel von xlThin auf xlHairline ] Fehler
End With
ThisWorkbook.Worksheets("Border3").Cells(i_Zl + 4, i_Sp - 1).Value = "xlEdgeRight " & s_Typ(i) & " F= " & i_TypF(j)
With ThisWorkbook.Worksheets("Border3").Range(ThisWorkbook.Worksheets("Border3").Cells(i_Zl + 5, i_Sp), ThisWorkbook.Worksheets("Border3").Cells(i_Zl + 5, i_Sp + 2)).Borders(xlEdgeTop) ' .Weight = i_Typ(i) ' xlThin
.LineStyle = xlLineStyleNone
' .LineStyle = xlContinuous ' <- beim 1. Durchlauf [ j=1; i=1 ] Fehler
' .ColorIndex = i_TypF(j) ' <- beim 7. Durchlauf [ j=3; i=1; wechsel von ColorIndex=24 auf ColorIndex=34 ] Fehler
' .Weight = i_Typ(i) ' <- beim 5. Durchlauf [ j=2; i=2; wechsel von xlThin auf xlHairline ] Fehler
End With
ThisWorkbook.Worksheets("Border3").Cells(i_Zl + 5, i_Sp - 1).Value = "xlEdgeTop " & s_Typ(i) & " F= " & i_TypF(j)
With ThisWorkbook.Worksheets("Border3").Range(ThisWorkbook.Worksheets("Border3").Cells(i_Zl + 6, i_Sp), ThisWorkbook.Worksheets("Border3").Cells(i_Zl + 7, i_Sp + 2)).Borders(xlInsideHorizontal) ' .Weight = i_Typ(i) ' xlThin
.LineStyle = xlLineStyleNone
' .LineStyle = xlContinuous ' <- beim 1. Durchlauf [ j=1; i=1 ] Fehler
' .ColorIndex = i_TypF(j) ' <- beim 7. Durchlauf [ j=3; i=1; wechsel von ColorIndex=24 auf ColorIndex=34 ] Fehler
' .Weight = i_Typ(i) ' <- beim 5. Durchlauf [ j=2; i=2; wechsel von xlThin auf xlHairline ] Fehler
End With
ActiveSheet.Cells(i_Zl + 6, i_Sp - 1).Value = "xlInsideHorizontal " & s_Typ(i) & " F= " & i_TypF(j)
With ThisWorkbook.Worksheets("Border3").Range(ThisWorkbook.Worksheets("Border3").Cells(i_Zl + 8, i_Sp), ThisWorkbook.Worksheets("Border3").Cells(i_Zl + 8, i_Sp + 2)).Borders(xlInsideVertical) ' .Weight = i_Typ(i) ' xlThin
.LineStyle = xlLineStyleNone
' .LineStyle = xlContinuous ' <- beim 1. Durchlauf [ j=1; i=1 ] Fehler
' .ColorIndex = i_TypF(j) ' <- beim 7. Durchlauf [ j=3; i=1; wechsel von ColorIndex=24 auf ColorIndex=34 ] Fehler
' .Weight = i_Typ(i) ' <- beim 5. Durchlauf [ j=2; i=2; wechsel von xlThin auf xlHairline ] Fehler
End With
ActiveSheet.Cells(i_Zl + 8, i_Sp - 1).Value = "xlInsideVertical " & s_Typ(i) & " F= " & i_TypF(j)
' i_Zl = 8
i_Sp = i_Sp + 5
Next i
Debug.Print
i_Zl = i_Zl + 10
i_Sp = 2
Next j
End <pre>Sub ' border3
Trotz Suche in Foren: habe keine Loesung(en) gefunden.
Bitte - wenn moeglich - um Info
Gruß
anno