Re: Austausch von Zellinhalten per Makro?
20.06.2003 12:23:23
Karsten J.
HalloJetzt geht e mit diesen Änderungen:
Option Explicit
Sub tauschen()
Dim xyz, wert3, x1, x2
xyz = 0
Dim R1 As Range, R2 As Range, F1 As String, F2 As String
On Error GoTo ende
Set R1 = Application.InputBox(prompt:="Zelle 1 auswählen...", Type:=8)
F1 = R1.FormulaLocal
Set R2 = Application.InputBox(prompt:="Zelle 2 auswählen...", Type:=8)
F2 = R2.FormulaLocal
If F1 = F2 Then
MsgBox "Unterschiedlich Zellen auswählen!"
Set R1 = Nothing: Set R2 = Nothing
Exit Sub
End If
x1 = R1
x2 = R2
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
test1:
xyz = xyz + 1
If xyz = 52 Then GoTo ende
Sheets("Besetzung").Select
Cells(xyz, 2).Select
wert3 = ActiveCell.Value
If R1 <> wert3 Then GoTo test1
If R1 = wert3 Then ActiveCell.FormulaR1C1 = x2
test2:
xyz = xyz + 1
If xyz = 60 Then xyz = 1
Sheets("Besetzung").Select
Cells(xyz, 2).Select
wert3 = ActiveCell.Value
If R2 <> wert3 Then GoTo test2
If R2 = wert3 Then ActiveCell.FormulaR1C1 = x1
ende:
Sheets("Drucken").Select
Range("a1").Select
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
Sheets("Drucken").Select
Range("a1").Select
End Sub
Jetzt ändere ich nicht die Formel, sondern den Wert ind den Unrsprungsfeldern.
MfG
Karsten