r/excel•
carabrianne

How can I turn this code into a loop statement?

Waiting on OP

I would like the code to perform a copy and paste for every 4th cell within a range until it reaches the end of the row, and then move to the next row and repeat the task until it reaches the end.

Right now, I have the following snippet repeated and have just entered the source and destination manually for each relevant cell.

Would this be a for next loop? Any help is appreciated!

Dim SourceWs as Worksheet Set SourceWs = Worksheets(Source Data) Dim Destination as Worksheet Set Destination = ThisWorkbook.Worksheets(“Interface”) Dim lastRow As Long

lastRow = SourceWs.Cells(1,1).SpecialCells(xlCellTypeVisible).End(xlDown).Row SourceWs.Range(“C2:C” & lastRow).SpecialCells(xlCellTypeVisible).Copy DestinationWs.Range(“A11”).PasteSpecial xlPaste Values

Posted May 6, 2022, 6:55 PM UTC

14
Loading comments…