Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1336to1340
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

Excel VBA Kopieren mit Format

Excel VBA Kopieren mit Format
21.11.2013 09:05:30
Stefan
Ich Kopiere Momentan meine Daten mit diesem Code. Das Format wird auch korrekt kopiert. Das Problem ist das er meine Verknüpften Zellen nicht mehr betrachtet.
Hier der Code wo das Format richtig kopiert wird (ohne das meine Verknüpften Zellen betrachtet werden)
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim intRow, lngSpalte
If Target.Address = "$A$2" Then
Cells(2, 2) = "Nichts Ausgewählt"
ElseIf Target.Address = "$B$2" Then
If Cells(2, 2)  "Nichts Ausgewählt" Then
With Sheets("Auswahl")
intRow = 2
'Zeilen hochzählen, bis zur 1. leeren Zeile in E:M
Do
'prüfen, ob Zellen in Spalten E bis M der Zeile leer sind
If Application.WorksheetFunction.CountA(.Range(.Cells(intRow, 5), _
.Cells(intRow, 14))) = 0 Then
If intRow > 2 Then
Application.EnableEvents = False
'Inhalte und Formate im Bereich E2:Mxxx löschen
.Range(.Cells(2, 5), .Cells(intRow - 1, 14)).Clear
Application.EnableEvents = True
End If
Exit Do
End If
intRow = intRow + 1
Loop
End With
For intRow = 1 To 300
If Target.Value = Worksheets("DP").Cells(intRow, 1).Value Then
With Sheets("DP")
If .Cells(intRow, 1).MergeCells = True Then 'Zellen in Spalte A _
sind verbunden
.Range(.Cells(intRow, 2), .Cells(intRow + _
.Cells(intRow, 1).MergeArea.Rows.Count - 1, 10)).Copy
Else
.Range(.Cells(intRow, 2), .Cells(intRow, 10)).Copy
End If
End With
Worksheets("DP").Range(Worksheets("DP").Cells(intRow, 2), Worksheets("DP").Cells(intRow, 10)). _
Copy Worksheets("Auswahl").Range(Worksheets("Auswahl").Cells(2, 5), Worksheets("Auswahl").Cells(2, 13))
Exit For
End If
Next intRow
End If
End If
End Sub
Hier der code wo die Verknüpften Zellen betrachtet werden aber leider das Format nicht richtig übertragen wird.
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim intRow, lngSpalte
If Target.Address = "$A$2" Then
Cells(2, 2) = "Nichts Ausgewählt"
ElseIf Target.Address = "$B$2" Then
If Cells(2, 2)  "Nichts Ausgewählt" Then
With Sheets("Auswahl")
intRow = 2
'Zeilen hochzählen, bis zur 1. leeren Zeile in E:M
Do
'prüfen, ob Zellen in Spalten E bis M der Zeile leer sind
If Application.WorksheetFunction.CountA(.Range(.Cells(intRow, 5), _
.Cells(intRow, 14))) = 0 Then
If intRow > 2 Then
Application.EnableEvents = False
'Inhalte und Formate im Bereich E2:Mxxx löschen
.Range(.Cells(2, 5), .Cells(intRow - 1, 14)).Clear
Application.EnableEvents = True
End If
Exit Do
End If
intRow = intRow + 1
Loop
End With
For intRow = 1 To 100
If Target.Value = Worksheets("DP").Cells(intRow, 1).Value Then
With Sheets("DP")
If .Cells(intRow, 1).MergeCells = True Then 'Zellen in Spalte A _
sind verbunden
.Range(.Cells(intRow, 2), .Cells(intRow + _
.Cells(intRow, 1).MergeArea.Rows.Count - 1, 10)).Copy
Else
.Range(.Cells(intRow, 2), .Cells(intRow, 10)).Copy
End If
End With
With Sheets("Auswahl")
Application.EnableEvents = False
.Cells(Target.Row, 5).PasteSpecial Paste:=xlPasteFormats, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=False
.Cells(Target.Row, 5).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Application.EnableEvents = True
End With
Exit For
End If
Next intRow
End If
End If
End Sub

Da ich wie schon gesagt nicht der VBA Crack bin bitte ich erneut um eure Hilfe.

3
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Excel VBA Kopieren mit Format
24.11.2013 21:36:48
fcs
Hallo Stefan,
der 2. Code sollte eigentlich schon die Formate kopieren.
Probleme könnten evtl. bedingte Formatierungen bereiten.
Gruß
Franz

AW: Excel VBA Kopieren mit Format
25.11.2013 14:07:40
Stefan
Hallo, wie gesagt der zweite Code macht eingentlich schon fast alles richtig. Nur er kopiert die zelle etwas falsch.
Richtig mit dem ersten Code:
Überschrift
Unterpunkt
Zweiter Code:
Überschrift
Unterpunkt
da übernimmt er das Format leider nicht richtig.

AW: Excel VBA Kopieren mit Format
28.11.2013 11:32:39
Stefan
Nun die Frage, wie löse ich das am besten ? :D
Anzeige

301 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige