Anzeige
Archiv - Navigation
1412to1416
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Formel einfügen per VBA

Formel einfügen per VBA
05.03.2015 10:49:39
Anton
Hallo!
Folgendes kleines Problem:
Ich habe folgendes Programm geschrieben, um mir eine Formel einzufügen (=RC[-14]*RC[-28]". Diese soll dann auch in den 12 Nebenstehenden Spalten bis unten eingetragen werden. Wie kann ich die Spalten beim Autofill hochzählen? (Soll von AF bis AR hochgezählt werden.

Dim Letzte33 As Long
Dim jkkk As Long
Dim Zellenindex As Long
jkkk = 32
Zellenindex = 32
Do Until jkkk = 44
Letzte33 = ActiveSheet.Cells(1048576, jkk).End(xlUp).Row
ActiveSheet.Cells(7, jkkk).Formula = "=RC[-14]*RC[-28]"
ActiveSheet.Cells(7, jkkk).AutoFill Destination:=Range(Zellenindex & "7", Zellenindex &  _
Letzte33)
jkkk = jkkk + 1
Loop
Ich hoffe ihr könnt mir weiter helfen.
MfG,
Anton Huber

6
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
Eine Fml in R1C1-Schreibweise ordnet man ...
05.03.2015 11:17:37
Luc:-?
…auch .FormulaR1C1 zu, Anton,
außerdem kann sie gleich in der von dir verwendeten relativen Schreibweise in alle Zellen eingetragen wdn, sie stimmt dann automatisch in jeder Zelle, was der Vorteil dieser Schreibweise ist.
Gruß, Luc :-?
Besser informiert mit …

AW: Formel einfügen per VBA
05.03.2015 11:18:20
EtoPHG
Hallo Anton,
Indem du dein ganzes Konstrukt auf eine einzige Codezeile verkürzt:
    Range(Cells(7, 32), Cells(7, 44)).FormulaR1C1 = "=RC[-14]*RC[-28]"
Gruess Hansueli

Anzeige
AW: Formel einfügen per VBA
05.03.2015 11:31:57
Anton
Hallo,
Damit geht mir aber das AutoFill Destination bis zum /// "AF7:AF" & Letzte33 /// flöten, oder?
Die Formel soll Quasi ein mal nach unten, bis zum Zellenwert "Letzte33" gefüllt werden und ein mal nach Rechts bis zu AR.
Früher hab ich quasi folgendes Konstrukt verwendet, welches ich nun vereinfachen möchte:

Dim Letzte33 As Long
Dim jkk As Long
Dim jkkk As Long
jkk = 30
jkkk = 32
Letzte33 = ActiveSheet.Cells(1048576, jkk).End(xlUp).Row 'Hier zählt er die Zeilenanzahl
ActiveSheet.Cells(7, jkkk).Formula = "=RC[-14]*RC[-28]"
ActiveSheet.Cells(7, jkkk).AutoFill Destination:=Range("AF7:AF" & Letzte33)
ActiveSheet.Cells(7, jkkk + 1).Formula = "=RC[-14]*RC[-28]"
ActiveSheet.Cells(7, jkkk + 1).AutoFill Destination:=Range("AG7:AG" & Letzte33)
ActiveSheet.Cells(7, jkkk + 2).Formula = "=RC[-14]*RC[-28]"
ActiveSheet.Cells(7, jkkk + 2).AutoFill Destination:=Range("AH7:AH" & Letzte33)
ActiveSheet.Cells(7, jkkk + 3).Formula = "=RC[-14]*RC[-28]"
ActiveSheet.Cells(7, jkkk + 3).AutoFill Destination:=Range("AI7:AI" & Letzte33)
ActiveSheet.Cells(7, jkkk + 4).Formula = "=RC[-14]*RC[-28]"
ActiveSheet.Cells(7, jkkk + 4).AutoFill Destination:=Range("AJ7:AJ" & Letzte33)
ActiveSheet.Cells(7, jkkk + 5).Formula = "=RC[-14]*RC[-28]"
ActiveSheet.Cells(7, jkkk + 5).AutoFill Destination:=Range("AK7:AK" & Letzte33)
ActiveSheet.Cells(7, jkkk + 6).Formula = "=RC[-14]*RC[-28]"
ActiveSheet.Cells(7, jkkk + 6).AutoFill Destination:=Range("AL7:AL" & Letzte33)
ActiveSheet.Cells(7, jkkk + 7).Formula = "=RC[-14]*RC[-28]"
ActiveSheet.Cells(7, jkkk + 7).AutoFill Destination:=Range("AM7:AM" & Letzte33)
ActiveSheet.Cells(7, jkkk + 8).Formula = "=RC[-14]*RC[-28]"
ActiveSheet.Cells(7, jkkk + 8).AutoFill Destination:=Range("AN7:AN" & Letzte33)
ActiveSheet.Cells(7, jkkk + 9).Formula = "=RC[-14]*RC[-28]"
ActiveSheet.Cells(7, jkkk + 9).AutoFill Destination:=Range("AO7:AO" & Letzte33)
ActiveSheet.Cells(7, jkkk + 10).Formula = "=RC[-14]*RC[-28]"
ActiveSheet.Cells(7, jkkk + 10).AutoFill Destination:=Range("AP7:AP" & Letzte33)
ActiveSheet.Cells(7, jkkk + 11).Formula = "=RC[-14]*RC[-28]"
ActiveSheet.Cells(7, jkkk + 11).AutoFill Destination:=Range("AQ7:AQ" & Letzte33)
ActiveSheet.Cells(7, jkkk + 12).Formula = "=RC[-14]*RC[-28]"
ActiveSheet.Cells(7, jkkk + 12).AutoFill Destination:=Range("AR7:AR" & Letzte33)

Ich will quasi das einfügen der Formeln auf eine Schleife zusammenfassen, die die Spalten hochzählt.
MfG,
Anton Huber

Anzeige
AW: Formel einfügen per VBA
05.03.2015 11:40:50
EtoPHG
Hallo Anton,
Ich hab meine lieben Not und Mühe, mit dem Lesen und Verstehen deiner Codes.
Dann halt:
Range(Cells(7, 32), Cells(Rows.Count, 30).End(xlUp).Offset(, 14)).FormulaR1C1 = "=RC[-14]*RC[-28]"

Gruess Hansueli

AW: Formel einfügen per VBA
05.03.2015 11:52:43
Anton
Dankeschön, klappt perfekt! :)
Grüße und schönen Tag wünsche ich dir.
Anton Huber

AW: Formel einfügen per VBA
05.03.2015 11:47:21
Klexy
Was bedeutet "Spalten beim Autofill hochzählen"?
Schreib mal die Formeln im Klartext, die jeweils in den Zellen AF7, AR7, AF12 und AR12 stehen sollen

314 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige