Selection.AutoFill
27.10.2004 03:30:17
robag
Die Zellen direkt darunter bleiben leer.Danach werden alle Formeln in diesen 6 Zellen mittels AutoFill nach unten übertragen.
Die Länge der Tabelle wird aber nach Spalte A bestimmt, somit muss sich AutoFill nach Spalte A richten. Mein Makro orientiert sich aber nur an dem Bereich der auch aufgefüllt werden soll. Der Bereich wird aber jeden Tag länger weil in den Spalten A bis I immer wieder neue Daten eingefügt werden.
Ich hoffe ich habe mich verständlich ausgedrückt.
Danke im Vorraus.
Wie muss ich das makro ändern?
Private Sub CommandButton1_Click()
Range("J4").Select
Selection.ClearContents
ActiveCell.FormulaR1C1 = "=IF(RC[-8]=R[1]C[-8],1,0)"
Columns("J:J").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="0"
Selection.FormatConditions(1).Font.ColorIndex = xlAutomatic
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _
Formula1:="1"
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="1"
Selection.FormatConditions(1).Interior.ColorIndex = 50
Range("K4").Select
ActiveCell.FormulaR1C1 = _
"=IF((RC[-3]+RC[-2])<(R[1]C[-3]+R[1]C[-2]),(R[1]C[-3]+R[1]C[-2])-(RC[-3]+RC[-2]),(RC[-3]+RC[-2])-(R[1]C[-3]+R[1]C[-2]))"
Range("L4").Select
ActiveCell.FormulaR1C1 = "=LEFT(RC[-8],SEARCH(""0"",RC[-8])-1)"
Range("L5").Select
Selection.ClearContents
Range("K5").Select
Selection.ClearContents
Range("J5").Select
Selection.ClearContents
Range("J4:L5").Select
Selection.AutoFill Destination:=Range("J4:L" & Cells(Rows.Count, 12).End(xlUp).Row), Type:=xlFillDefault
Range("J4:L" & Cells(Rows.Count, 12).End(xlUp).Row).Select
Range("K4:K" & Cells(Rows.Count, 11).End(xlUp).Row).Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, _
Formula1:="=$K$2"
Selection.FormatConditions(1).Interior.ColorIndex = 50
Range("A1").Select
End Sub