Betrifft: Kopieren der Formel aktive Spalte
von: walli
Guten Morgen,
ich habe ein Makro (auch über Forum), für das Kopieren der
Formel.
Public Sub Spalte_Aktive_Formel_kopieren()
Application.Calculation = xlCalculationManual
Dim i As Long
With ActiveSheet
For i = 4 To .Cells(.Rows.Count, 1).End(xlUp).Row
.Cells(i, 30).Value = "=RC[-9]*1" ' zb. spalte 9 von Spalte AD aus gezählt
Next
End With
Application.Calculation = xlCalculationAutomatic
End Sub
Nun möchte ich, wenn ich auf einer Spalte stehe, das ich ab Zeile 4 die Formel
Betrifft: AW: Kopieren der Formel aktive Spalte
von: welga
Public Sub Spalte_Aktive_Formel_kopieren()
Application.Calculation = xlCalculationManual
Dim i As Long, actspal As Long
With ActiveSheet
actspal = ActiveCell.Column
For i = 4 To .Cells(.Rows.Count, 1).End(xlUp).Row
.Cells(i, actspal).Value = "=RC[-9]*1" ' zb. spalte 9 von Spalte AD aus gezä _
hlt
Next
End With
Application.Calculation = xlCalculationAutomatic
End Sub
Betrifft: Die Formel sollte aktuell übernommen
von: walli
Geschrieben am: 08.01.2010 09:40:51
Guten Morgen Welga,
nicht ganz.
Die Formel sollte aus der aktuelle Spalte von der Zelle 4 übernommen
werden.
Wenn ich also in der Spalte T stehe sollte die Formel aus der Spalte T4 bis
zum Ende kopiert werden.
mfg walli
Betrifft: AW: Die Formel sollte aktuell übernommen
von: welga
Public Sub Spalte_Aktive_Formel_kopieren()
Dim i As Long, actspal As Long
Dim formel As Variant
With ActiveSheet
actspal = ActiveCell.Column
Application.Calculation = xlCalculationManual
formel = .Cells(4, actspal).Formula
For i = 5 To .Cells(.Rows.Count, 1).End(xlUp).Row
.Cells(i, actspal).Value = formel
Next
End With
Application.Calculation = xlCalculationAutomatic
End Sub
Betrifft: Kopiert ja aber
von: walli
Geschrieben am: 08.01.2010 10:22:13
Hey Welga,
danke erst mal !
Kopiert ja aber die Formel verändert sich nicht.
Wenn ich z.b. nach unten ziehe, dann wird die Formel ja
entsprechend der nächsten Zeile angepasst.
mfg walli
Betrifft: Kenntnisse zu gering
von: welga
Geschrieben am: 08.01.2010 10:26:53
Hallo,
dachte die Formel aus zeile 4 soll nach unten statisch kopiert werden. Dynamisch wird wohl etwas schwierig, da sind meine Kenntnisse zu gering.
Vielleicht kann dir ja jemand anderes helfen.
Gruß
welga
Betrifft: AW: Kenntnisse zu gering
von: Ramses
Public Sub Spalte_Aktive_Formel_kopieren()
Dim actspal As Long
With ActiveSheet
actspal = ActiveCell.Column
Application.Calculation = xlCalculationManual
.Cells(4, actspal).Copy
With .Range(.Cells(5, actspal), .Cells(.Cells(.Rows.Count, 1).End(xlUp).Row, actspal))
ActiveSheet.Paste
End With
Application.Calculation = xlCalculationAutomatic
End With
End Sub
Gruss Rainer
Betrifft: Das läuft, kann man ...
von: walli
Geschrieben am: 08.01.2010 10:52:55
Hallo Rainer,
danke für die weitere Unterstützung, es läuft.
Könnte man zur Sicherheit eine Abfrage einbauen,
wenn man nicht in der Zeile 4 steht HINWEIS bzw. Abruch ?
mfg walli
Betrifft: AW: Das läuft, kann man ...
von: Ramses
Public Sub Spalte_Aktive_Formel_kopieren()
Dim actspal As Long
If ActiveCell.Row <> 4 Then
MsgBox "Keine Zelle in Zeile 4 ausgewählt", vbCritical + vbOKOnly, "Fehler"
Exit Sub
End If
With ActiveSheet
actspal = ActiveCell.Column
Application.Calculation = xlCalculationManual
.Cells(4, actspal).Copy
With .Range(.Cells(5, actspal), .Cells(.Cells(.Rows.Count, 1).End(xlUp).Row, actspal))
ActiveSheet.Paste
End With
Application.Calculation = xlCalculationAutomatic
End With
End Sub
Gruss Rainer
Betrifft: Danke für die Abfrag, es wird doch nicht
von: walli
Geschrieben am: 08.01.2010 11:46:47
Hallo Rainer,
Abfrage passsst !
Leider wird die bestehende Formel aus der Zelle 4 in der aktiven Spalte
nicht kompl. bis zum Ende nach unten kopiert.
mfg Walli
Betrifft: AW: Danke für die Abfrag, es wird doch nicht
von: Ramses
Betrifft: Da ist beim kopieren was verloren gegangen...
von: Ramses
Geschrieben am: 08.01.2010 12:44:40
Hallo
Sorry,... habe gerade gesehen, dass da beim kopieren irgendwo was verloren gegangen ist.
Die Zeile muss natürlich so heissen
With .Range(.Cells(5, actspal), .Cells(.Cells(.Rows.Count, 1).End(xlUp).Row, actspal)).Select
Gruss Rainer
Betrifft: Einwandfrei Danke Rainer -)))
von: walli
Geschrieben am: 08.01.2010 12:58:15
Betrifft: ja, aber...
von: welga
Public Sub Spalte_Aktive_Formel_kopieren()
Dim actspal As Long, i As Long
With ActiveSheet
actspal = ActiveCell.Column
Application.Calculation = xlCalculationManual
.Cells(4, actspal).Copy
For i = 5 To .Cells(.Rows.Count, 1).End(xlUp).Row
Cells(i, actspal).Select
ActiveSheet.Paste
Next i
Application.Calculation = xlCalculationAutomatic
End With
End Sub
Betrifft: ?????????????
von: Ramses
Betrifft: Hallo Welga, ja damit wird bis unten kopiert !
von: walli
Geschrieben am: 08.01.2010 11:48:58
Betrifft: Danke, Welga, für die bisherige Unterstütung !!!
von: walli
Geschrieben am: 08.01.2010 10:51:05