marta.kroll@me.com
17.04.2020 13:04:21
Ledi
ich habe über VBA einen Code geschrieben, der Zellen verkettet, in denen bei Spalte P ein Wert steht. Das wird für Zeile 2 bis 15 geprüft und alle Verkettungen sollen dann zum Schluss in eine Zelle geschrieben werden.
Meine Frage geht das vielleicht auch leichter? Mit einer For-Schleife?
Danke für die Hilfe.
VG
Sub Verkettung()
With Worksheets("Ein- und Ausgabe")
If .Cells(2, 16).Value "" Then
a = .Cells(2, 4).Value & ":" & .Cells(2, 16).Value
End If
If .Cells(3, 16).Value "" Then
b = .Cells(3, 4).Value & ":" & .Cells(3, 16).Value
End If
If .Cells(4, 16).Value "" Then
c = .Cells(4, 4).Value & ":" & .Cells(4, 16).Value
End If
If .Cells(5, 16).Value "" Then
d = .Cells(5, 4).Value & ":" & .Cells(5, 16).Value
End If
If .Cells(6, 16).Value "" Then
e = .Cells(6, 4).Value & ":" & .Cells(6, 16).Value
End If
If .Cells(7, 16).Value "" Then
f = .Cells(7, 4).Value & ":" & .Cells(7, 16).Value
End If
If .Cells(8, 16).Value "" Then
g = .Cells(8, 4).Value & ":" & .Cells(8, 16).Value
End If
If .Cells(9, 16).Value "" Then
h = .Cells(9, 4).Value & ":" & .Cells(9, 16).Value
End If
If .Cells(10, 16).Value "" Then
i = .Cells(10, 4).Value & ":" & .Cells(10, 16).Value
End If
If .Cells(11, 16).Value "" Then
j = .Cells(11, 4).Value & ":" & .Cells(11, 16).Value
End If
If .Cells(12, 16).Value "" Then
k = .Cells(12, 4).Value & ":" & .Cells(12, 16).Value
End If
If .Cells(13, 16).Value "" Then
l = .Cells(13, 4).Value & ":" & .Cells(13, 16).Value
End If
If .Cells(14, 16).Value "" Then
m = .Cells(14, 4).Value & ":" & .Cells(14, 16).Value
End If
If .Cells(15, 16).Value "" Then
n = .Cells(15, 4).Value & ":" & .Cells(15, 16).Value
End If
.Cells(2, 30).Value = a & Chr(10) & b & Chr(10) & c & Chr(10) & d & Chr(10) & e & Chr(10) & f & _
_
_
_
Chr(10) & g & Chr(10) & h & Chr(10) & i & Chr(10) & j & Chr(10) & k & Chr(10) & l & Chr(10) & m _
_
_
& Chr(10) & n
End With
End Sub