mrtb
06-26-2018, 02:28 AM
Hello everyone,
currently I am struggling with a double do...loop. This is what I got so far ...
bb = maxWied
tt = maxWied - 1
x = 2
Do While Cells(x, 24).Value <> ""
'Cells(x, 23).Value = "-" & Cells(x, (23 + bb) - tt).Value
Do While tt >= 0 'And Cells(x, (23 + bb) - tt) <> ""
Cells(x, 23).Value = Cells(x, 23).Value & vbCrLf & "-" & Cells(x, (23 + bb) - tt).Value
tt = tt - 1
Loop
x = x + 1
Loop
The first loop shall copy all content from the following columns (if filled) into the first one. The number of filled columns varies per line and the total number may vary as well as these are created by another vba code. "MaxWied" represents the greatest number of columns following the cell where the contents shall be copied into. Afterwards the process shall be repeated for all lines in the document (2nd loop).
Unfortunatley Idk why its not working and it would be great if someone could help me out as I am pretty inexperiences in coding ...
Thanks a lot in advance!
currently I am struggling with a double do...loop. This is what I got so far ...
bb = maxWied
tt = maxWied - 1
x = 2
Do While Cells(x, 24).Value <> ""
'Cells(x, 23).Value = "-" & Cells(x, (23 + bb) - tt).Value
Do While tt >= 0 'And Cells(x, (23 + bb) - tt) <> ""
Cells(x, 23).Value = Cells(x, 23).Value & vbCrLf & "-" & Cells(x, (23 + bb) - tt).Value
tt = tt - 1
Loop
x = x + 1
Loop
The first loop shall copy all content from the following columns (if filled) into the first one. The number of filled columns varies per line and the total number may vary as well as these are created by another vba code. "MaxWied" represents the greatest number of columns following the cell where the contents shall be copied into. Afterwards the process shall be repeated for all lines in the document (2nd loop).
Unfortunatley Idk why its not working and it would be great if someone could help me out as I am pretty inexperiences in coding ...
Thanks a lot in advance!