Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
280to284
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
280to284
280to284
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

Formeln in das VBA Makro einbinden?

Formeln in das VBA Makro einbinden?
22.07.2003 09:21:46
Selma
Halli Hallo,
ich brauche Hilfe bei Ergänzung meines Makros:


Sub SpalteH_to_SpalteB()
'alle Zelleninhalte aus Spalte H ab Zeile 2 werden in Spalte B kopieren (als Werte)
Dim letzte As Long
If [H65536] = "" Then
letzte = [H65536].End(xlUp).Row
Else
letzte = 65536
End If
Range("K2:K" & letzte).Copy
Range("B2").PasteSpecial Paste:=xlValues           ' Werte
'Schriftfarbe Anfang
With Selection.Font
.Name = "Arial"
.Size = 8
.ColorIndex = 10
End With
'Schriftfarbe Ende
Application.CutCopyMode = False
End Sub

Wenn das Makro ausgeführt wird, möchte ich noch diese Formel in das Makro einbinden:
Bereich A2:letzte Zelle = eine 2 soll eingetragen werden
Bereich C2:letzte Zelle = das Wort Produkt soll eingetragen werden
Bereich D2:letzte Zelle = ein 00 soll eingetragen werden
Bereich E2:letzte Zelle = diese Formel z.B. für Zeile 145 =WENN(ODER(ISTLEER($C145);ISTLEER($D145);ISTLEER($I145));"";WENN($D145<=9;VERKETTEN($C145;" ";"-";" ";"0";$D145;" ";"-";" ";$I145);VERKETTEN($C145;" ";"-";" ";$D145;" ";"-";" ";$I145)))
Bereich G2:letzte Zelle = diese Formel z.B. für Zeile 145 =J145&E145
Bereich H2:letzte = diese Formel z.B. für Zeile 145 =WENN(ODER(ISTLEER($B145);ISTLEER($F145);ISTLEER($J145));"";VERKETTEN("rename";" ";"""";$F145;"""";" ";"""";$E145;""""))
Bereich I2:letzte Zelle = diese Formel z.B. für Zeile 145 =WENN(B145="";"";WENN(ISTFEHLER(FINDEN("-";B145;1));B1063;TEIL($B145;SUCHEN("##";WECHSELN($B145;"-";"##";LÄNGE($B145)-LÄNGE(WECHSELN($B145;"-";""))))+$A145;200)))
Bereich J2:letzte Zelle = diese Formel z.B. für Zeile 145 =WENN($F145="";"";LINKS($F145;FINDEN("##";WECHSELN($F145;"\";"##";LÄNGE($F145)-LÄNGE(WECHSELN($F145;"\";""))))))
Bereich K2:letzte Zelle = diese Formel z.B. für Zeile 145 =WENN($F145="";"";TEIL($F145;SUCHEN("##";WECHSELN($F145;"\";"##";LÄNGE($F145)-LÄNGE(WECHSELN($F145;"\";""))))+1;200))
Danke im voraus...
Liebe Grüße aus Düsseldorf
Selma

5
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Formeln in das VBA Makro einbinden?
22.07.2003 09:59:55
Michael Scheffler
Hi Selma,
zeichne Dir den Kram doch auf, ist am einfachsten.
Gruß
Micha

AW: Formeln in das VBA Makro einbinden?
22.07.2003 11:07:48
Selma
Hi Micha,
ich habe es aufzeichnen lassen und mein Code sieht jetzt so aus:

Sub Formeln()
'alle Zelleninhalte aus Spalte H ab Zeile 2 werden in Spalte B kopieren (als Werte)
Dim letzte As Long
If [H65536] = "" Then
letzte = [H65536].End(xlUp).Row
Else
letzte = 65536
End If
Range("K2:K" & letzte).Copy
Range("B2").PasteSpecial Paste:=xlValues
'Schriftfarbe Anfang
With Selection.Font
.Name = "Arial"
.Size = 8
.ColorIndex = 10
End With
'Schriftfarbe Ende
Application.CutCopyMode = False
Range("A2:A5000").FormulaR1C1 = "2"
Range("C2:C5000").FormulaR1C1 = "Produkt"
Range("D2:D5000").FormulaR1C1 = "00"
Range("E2:E5000").FormulaR1C1 = "=IF(OR(ISBLANK(R[143]C3),ISBLANK(R[143]C4),ISBLANK(R[143]C9)),"""",IF(R[143]C4<=9,CONCATENATE(R[143]C3,"" "",""-"","" "",""0"",R[143]C4,"" "",""-"","" "",R[143]C9),CONCATENATE(R[143]C3,"" "",""-"","" "",R[143]C4,"" "",""-"","" "",R[143]C9)))"
Range("G2:G5000").FormulaR1C1 = "=R[133]C[4]&R[133]C[-1]"
Range("H2:H5000").FormulaR1C1 = "=IF(OR(ISBLANK(R[133]C2),ISBLANK(R[133]C6),ISBLANK(R[133]C10)),"""",CONCATENATE(""rename"","" "","""""""",R[133]C6,"""""""","" "","""""""",R[133]C5,""""""""))"
Range("I2:I5000").FormulaR1C1 = "=IF(R[133]C[-7]="""","""",IF(ISERROR(FIND(""-"",R[133]C[-7],1)),R[1051]C[-7],MID(R[133]C2,SEARCH(""##"",SUBSTITUTE(R[133]C2,""-"",""##"",LEN(R[133]C2)-LEN(SUBSTITUTE(R[133]C2,""-"",""""))))+R[133]C1,200)))"
Range("J2:J5000").FormulaR1C1 = "=IF(R[133]C6="""","""",LEFT(R[133]C6,FIND(""##"",SUBSTITUTE(R[133]C6,""\"",""##"",LEN(R[133]C6)-LEN(SUBSTITUTE(R[133]C6,""\"",""""))))))"
Range("K2:K5000").FormulaR1C1 = "=IF(R[133]C6="""","""",MID(R[133]C6,SEARCH(""##"",SUBSTITUTE(R[133]C6,""\"",""##"",LEN(R[133]C6)-LEN(SUBSTITUTE(R[133]C6,""\"",""""))))+1,200))"
End Sub

Zur Zeit werden die Formeln bis Zeile 5000 eingetragen. Was muß ich ändern,
damit die nur eingetragen werden bis letzte Zeile in Spalte B?
Danke....
Gruß
Selma

Anzeige
AW: Formeln in das VBA Makro einbinden?
22.07.2003 11:07:35
Selma
Hi Micha,
ich habe es aufzeichnen lassen und mein Code sieht jetzt so aus:

Sub Formeln()
'alle Zelleninhalte aus Spalte H ab Zeile 2 werden in Spalte B kopieren (als Werte)
Dim letzte As Long
If [H65536] = "" Then
letzte = [H65536].End(xlUp).Row
Else
letzte = 65536
End If
Range("K2:K" & letzte).Copy
Range("B2").PasteSpecial Paste:=xlValues
'Schriftfarbe Anfang
With Selection.Font
.Name = "Arial"
.Size = 8
.ColorIndex = 10
End With
'Schriftfarbe Ende
Application.CutCopyMode = False
Range("A2:A5000").FormulaR1C1 = "2"
Range("C2:C5000").FormulaR1C1 = "Produkt"
Range("D2:D5000").FormulaR1C1 = "00"
Range("E2:E5000").FormulaR1C1 = "=IF(OR(ISBLANK(R[143]C3),ISBLANK(R[143]C4),ISBLANK(R[143]C9)),"""",IF(R[143]C4<=9,CONCATENATE(R[143]C3,"" "",""-"","" "",""0"",R[143]C4,"" "",""-"","" "",R[143]C9),CONCATENATE(R[143]C3,"" "",""-"","" "",R[143]C4,"" "",""-"","" "",R[143]C9)))"
Range("G2:G5000").FormulaR1C1 = "=R[133]C[4]&R[133]C[-1]"
Range("H2:H5000").FormulaR1C1 = "=IF(OR(ISBLANK(R[133]C2),ISBLANK(R[133]C6),ISBLANK(R[133]C10)),"""",CONCATENATE(""rename"","" "","""""""",R[133]C6,"""""""","" "","""""""",R[133]C5,""""""""))"
Range("I2:I5000").FormulaR1C1 = "=IF(R[133]C[-7]="""","""",IF(ISERROR(FIND(""-"",R[133]C[-7],1)),R[1051]C[-7],MID(R[133]C2,SEARCH(""##"",SUBSTITUTE(R[133]C2,""-"",""##"",LEN(R[133]C2)-LEN(SUBSTITUTE(R[133]C2,""-"",""""))))+R[133]C1,200)))"
Range("J2:J5000").FormulaR1C1 = "=IF(R[133]C6="""","""",LEFT(R[133]C6,FIND(""##"",SUBSTITUTE(R[133]C6,""\"",""##"",LEN(R[133]C6)-LEN(SUBSTITUTE(R[133]C6,""\"",""""))))))"
Range("K2:K5000").FormulaR1C1 = "=IF(R[133]C6="""","""",MID(R[133]C6,SEARCH(""##"",SUBSTITUTE(R[133]C6,""\"",""##"",LEN(R[133]C6)-LEN(SUBSTITUTE(R[133]C6,""\"",""""))))+1,200))"
End Sub

Zur Zeit werden die Formeln bis Zeile 5000 eingetragen. Was muß ich ändern,
damit die nur eingetragen werden bis letzte Zeile in Spalte B?
Danke....
Gruß
Selma

Anzeige
AW: Formeln in das VBA Makro einbinden?
22.07.2003 11:44:10
Selma
naja ich sehe es jetzt das:
Range("A2:A5000").FormulaR1C1 = "2"
Range("C2:C5000").FormulaR1C1 = "Produkt"
Range("D2:D5000").FormulaR1C1 = "00"
Range("E2:E5000").FormulaR1C1 = "=IF(OR(ISBLANK(R[143]C3),ISBLANK(R[143]C4),ISBLANK(R[143]C9)),"""",IF(R[143]C4<=9,CONCATENATE(R[143]C3,"" "",""-"","" "",""0"",R[143]C4,"" "",""-"","" "",R[143]C9),CONCATENATE(R[143]C3,"" "",""-"","" "",R[143]C4,"" "",""-"","" "",R[143]C9)))"
Range("G2:G5000").FormulaR1C1 = "=R[133]C[4]&R[133]C[-1]"
Range("H2:H5000").FormulaR1C1 = "=IF(OR(ISBLANK(R[133]C2),ISBLANK(R[133]C6),ISBLANK(R[133]C10)),"""",CONCATENATE(""rename"","" "","""""""",R[133]C6,"""""""","" "","""""""",R[133]C5,""""""""))"
Range("I2:I5000").FormulaR1C1 = "=IF(R[133]C[-7]="""","""",IF(ISERROR(FIND(""-"",R[133]C[-7],1)),R[1051]C[-7],MID(R[133]C2,SEARCH(""##"",SUBSTITUTE(R[133]C2,""-"",""##"",LEN(R[133]C2)-LEN(SUBSTITUTE(R[133]C2,""-"",""""))))+R[133]C1,200)))"
Range("J2:J5000").FormulaR1C1 = "=IF(R[133]C6="""","""",LEFT(R[133]C6,FIND(""##"",SUBSTITUTE(R[133]C6,""\"",""##"",LEN(R[133]C6)-LEN(SUBSTITUTE(R[133]C6,""\"",""""))))))"
Range("K2:K5000").FormulaR1C1 = "=IF(R[133]C6="""","""",MID(R[133]C6,SEARCH(""##"",SUBSTITUTE(R[133]C6,""\"",""##"",LEN(R[133]C6)-LEN(SUBSTITUTE(R[133]C6,""\"",""""))))+1,200))"

auch falsch ist, weil es auf bestimmte Zelle bezieht (R[133] usw. :(

Anzeige
AW: Formeln in das VBA Makro einbinden?
22.07.2003 13:23:47
Michael Scheffler
Hi Selma,
Hier im Forum gefunden:

Sub Meldungen()
MsgBox Selection.Cells.Address
MsgBox Selection.Cells(1).Address
MsgBox ActiveSheet.UsedRange.Address
MsgBox Cells.SpecialCells(xlCellTypeLastCell).Address
MsgBox Cells.SpecialCells(xlCellTypeLastCell).Count
MsgBox Cells.SpecialCells(xlCellTypeLastCell).NumberFormatLocal
MsgBox Cells.SpecialCells(xlCellTypeLastCell).Row
MsgBox Cells.SpecialCells(xlCellTypeLastCell).Column
End Sub


311 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige