Excel: Rahmen von variablem Bereich zeichnen

Hallo!

Ich möchte einen Rahmen um den Breich von C1 bis Dx zeichnen, wobei x eine Variable vom Typ integer ist.

Wie kann ich dies realisieren?

Gruß Falk

Meine bisherige Lösung besteht darin, die Zellen mit einer For-Schleife zu durchlaufen und den Rahmen somit Zelle für Zelle zu zeichnen.

Hallo!

Hi,
wenn der Rahmen nur um den gesamten Bereich gehen soll, so:

 Dim a As Range
 Set a = Range(Cells(1, 2), Cells(14, 7))
 a.Borders(xlDiagonalDown).LineStyle = xlNone
 a.Borders(xlDiagonalUp).LineStyle = xlNone
 With a.Borders(xlEdgeLeft)
 .LineStyle = xlContinuous
 .Weight = xlThin
 .ColorIndex = xlAutomatic
 End With
 With a.Borders(xlEdgeTop)
 .LineStyle = xlContinuous
 .Weight = xlThin
 .ColorIndex = xlAutomatic
 End With
 With a.Borders(xlEdgeBottom)
 .LineStyle = xlContinuous
 .Weight = xlThin
 .ColorIndex = xlAutomatic
 End With
 With a.Borders(xlEdgeRight)
 .LineStyle = xlContinuous
 .Weight = xlThin
 .ColorIndex = xlAutomatic
 End With
 a.Borders(xlInsideVertical).LineStyle = xlNone
 a.Borders(xlInsideHorizontal).LineStyle = xlNone

Soll auch um jede eingeschlossene Zelle ein Rahmen sein so:

 Dim a As Range
 Set a = Range(Cells(1, 1), Cells(4, 4))
 a.Borders(xlDiagonalDown).LineStyle = xlNone
 a.Borders(xlDiagonalUp).LineStyle = xlNone
 With a.Borders(xlEdgeLeft)
 .LineStyle = xlContinuous
 .Weight = xlThin
 .ColorIndex = xlAutomatic
 End With
 With a.Borders(xlEdgeTop)
 .LineStyle = xlContinuous
 .Weight = xlThin
 .ColorIndex = xlAutomatic
 End With
 With a.Borders(xlEdgeBottom)
 .LineStyle = xlContinuous
 .Weight = xlThin
 .ColorIndex = xlAutomatic
 End With
 With a.Borders(xlEdgeRight)
 .LineStyle = xlContinuous
 .Weight = xlThin
 .ColorIndex = xlAutomatic
 End With
 With a.Borders(xlInsideVertical)
 .LineStyle = xlContinuous
 .Weight = xlThin
 .ColorIndex = xlAutomatic
 End With
 With a.Borders(xlInsideHorizontal)
 .LineStyle = xlContinuous
 .Weight = xlThin
 .ColorIndex = xlAutomatic
 End With

In der zweiten Zeile wird der Bereich gewählt:
von Zeile 1/Spalte 2 bis hin zu Zeile 14/Spalte 7
In deinem Beispiel müsste es heißen:
Set a = Range(Cells(1, 3), Cells(x, 4))

Ich möchte einen Rahmen um den Breich von C1 bis Dx zeichnen,
wobei x eine Variable vom Typ integer ist.

Wie kann ich dies realisieren?

Gruß.Timo

Gruß Falk

Danke!
Vielen Dank Timo!

dim a as Range
Set a = Range(Cells(1, 3), Cells(x, 4))

ist genau die Anweisung, die ich gesucht habe.

Gruß Falk