Für Formatierung leere Zeile finden

Hallo Freunde der Sonne,

ich habe folgendes Problem. Ich lese mir aus SAP eine Stückliste aus und möchte diese dann in Excel formatiren. Soweit so gut hab leider keine Ahnung von programmieren also habe ich das mit dem Makrorecorder gemacht, klappt auch alles super wie es will. Nur sind Stücklisten ja nicht statisch die eine ist länger als die andere hat also mehr Zeilen. Wie kann ich es machen, dass er merkt die Zeile ist leer hier höre ich also auf mit der Formatierung?

HOffe ich konnte mein Problem schildern und ihr könnte mir helfen.

Danke im Voraus.

Gruß

Stefan

Hallo Stevi,

zeige mal dein Makro.

Gruß
Reinhard

Hallo Reinhard,

Rows(„2:35“).Select
Selection.RowHeight = 25
With Selection
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range(„A2:B2“).Select
Selection.Font.Bold = True
Range(„J5“).Select
Range(„A2:H35“).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Range(„C2:C35“).Select
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With
Range(„E2:E35“).Select
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With
Range(„A2:B2“).Select
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
Range(„L6“).Select

With ActiveSheet.PageSetup
.PrintTitleRows = „$1:blush:1“
.PrintTitleColumns = „“
End With

Danke erstmal das du lust hast mir helfen zu wollen.

Also in dem Beispiel geht die ganze Formatierung immer bis Zeile 35 das müsste aber bis zur letzten gefüllten Zeile gehen.

Gruß

Stefan

Hallo Stefan,

probiers mal so:

Option Explicit
'
Sub tt()
Dim N As Byte, Zei As Long
Zei = Cells(Rows.Count, 1).End(xlUp).Row
With Range("A2:H" & Zei)
 .RowHeight = 25
 .VerticalAlignment = xlCenter
 .WrapText = False
 .Orientation = 0
 .AddIndent = False
 .ShrinkToFit = False
 .ReadingOrder = xlContext
 .MergeCells = False
 .Borders(xlDiagonalDown).LineStyle = xlNone
 .Borders(xlDiagonalUp).LineStyle = xlNone
 For N = 7 To 12
 With .Borders(N)
 .LineStyle = xlContinuous
 .Weight = xlThin
 .ColorIndex = xlAutomatic
 End With
 Next N
End With
With Range("E2:E" & Zei).Interior
 .ColorIndex = 36
 .Pattern = xlSolid
End With
With Range("C2:C" & Zei).Interior
 .ColorIndex = 36
 .Pattern = xlSolid
End With
With Range("A2:B2")
 .Font.Bold = True
 .Interior.ColorIndex = 3
 .Interior.Pattern = xlSolid
End With
Range("L6").Select
With ActiveSheet.PageSetup
 .PrintTitleRows = "$1:blush:1"
 .PrintTitleColumns = ""
End With
End Sub

Gruß
Reinhard