0

Here my code:

Sub Makro2()
    Sheets("Sheet1").Select    
    For i = 1 To 230
    Sheets("Sheet1").Select
        If IsEmpty(Cells(2 + i, 2)) = False Then
            Range("C3,M3:X3").Select
            Selection.Copy
            Sheets("Sheet2").Select
            Cells(2 + i, 1).Select
            ActiveSheet.Paste
        End If

    Next i

    Sheets("Sheet2").Select
    End Sub

The range : Range("C3,M3:X3").Select is static. How can I dynamically code it so I can use the iteration ? I tried something like this Range("Cells(2 + i, 3), Cells(2 + i, 13), Cells(2 + i, 14)") but it doesn't work. I've seen a lot of examples with a range but nothing how I can select multiple cells.

Thanks in advance.

BigBen
  • 46,229
  • 7
  • 24
  • 40
  • 1
    `Range("C" & i & ",M" & i & ":X" & i)`... but [don't select](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba). – BigBen Apr 15 '20 at 14:57
  • 2
    ^^^^^ `Sheets("Sheet1").Range("C" & i & ",M" & i & ":X" & i").Copy Sheets("Sheet2").Cells(2 + i, 1)` – Scott Craner Apr 15 '20 at 14:58
  • Thanks guys. It works like a charm. @ScottCraner The " after the last i must be deleted. – user2428412 Apr 20 '20 at 07:40

0 Answers0