Ich habe vier Arbeitsblätter und ich schreibe eine Formel in Zelle F2, die eine Füllung für den Rest auslösen. Ich habe bereits den Auslöser private Sub, um meine Prozedur, die funktioniert, aufzurufen. Gibt es eine Möglichkeit, dieses U-Boot effizienter zu machen?Trigger Filldown-Formel basierend auf Zelle eines anderen Arbeitsblatts
Option Explicit
Sub FillDownFormula_test2()
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Filldown a formula for in column of data.
' Assumes a data table with headings in the first row,
' the formula in the second row and is the active cell.
' this one is tested based on set range
' Test results were positive
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim rng As Range, rng2 As Range
Dim rngData As Range
Dim rngFormula As Range, rng2Formula As Range
Dim rowData As Long
Dim colData As Long
Dim wb As Workbook: Set wb = ThisWorkbook
Dim ws As Worksheet, ws2 As Worksheet
Set ws = wb.Sheets("Feuil1")
With ws
' Set the ranges
Set rng = wb.Sheets("Feuil1").Range("F2")
Set rngData = rng.CurrentRegion
' Set the row and column variables
rowData = rngData.CurrentRegion.Rows.Count
colData = rng.Column
' Set the formula range and fill down the formula
Set rngFormula = rngData.Offset(1, colData - 1).Resize(rowData - 1, 1)
rngFormula.FillDown
'G2 is a different formulas but same on every sheets
Set rng2 = wb.Sheets("Feuil1").Range("G2")
' Set the row and column variables
rowData = rngData.CurrentRegion.Rows.Count
colData = rng2.Column
' Set the formula range and fill down the formula
Set rng2Formula = rngData.Offset(1, colData - 1).Resize(rowData - 1, 1)
rng2Formula.FillDown
End With
With ws2
Set rng = wb.Sheets("Feuil2").Range("F2")
Set rngData = rng.CurrentRegion
' Set the row and column variables
rowData = rngData.CurrentRegion.Rows.Count
colData = rng.Column
' Set the formula range and fill down the formula
Set rngFormula = rngData.Offset(1, colData - 1).Resize(rowData - 1, 1)
rngFormula.FillDown
Set rng2 = wb.Sheets("Feuil2").Range("G2")
' Set the row and column variables
rowData = rngData.CurrentRegion.Rows.Count
colData = rng2.Column
' Set the formula range and fill down the formula
Set rng2Formula = rngData.Offset(1, colData - 1).Resize(rowData - 1, 1)
rng2Formula.FillDown
End With
End Sub
Eine letzte Frage: Was ist die effizienteste gewesen wäre ein Bereich an der Zeit zu tun, damit es mir Formel eingeben können, bevor die zweite zu tun. (Ich habe sechs Formeln filldown)
danke
ich es versucht, aber es sieht aus wie eine unvollendete Schleife auf größere Liste – Mdh
I don‘ Ich sehe hier überhaupt eine Schleife, ich bin mir nicht sicher, was Sie meinen ... Versuchen Sie auch, 'Debug.Printer' irgendwo zu verwenden, um zu debuggen, wo es aufhört – Maldred
Debug wird helfen, warum es weiterläuft? Ok, ich werde es versuchen. Ich weiß nicht, dass es alleine funktioniert, aber mit dem Ereignisauslöser hört es nie auf. Wie auch immer, ich werde zu dir zurückkommen – Mdh