# Off Topic > Hello..Introduce yourself >  >  Macro Variable Range

## jeff_e_84

I am trying to write a Macro that will copy and paste data from one sheet to another based on certain criteria.  I need the macro to copy cells Ai:Ki if any of the cells Ii, Ji or Ki contain a number.  I tried to set up i as an integer from 6 to 10000.  The macro is hung up on the the second line of code where I select my Range to copy.  Any help would be greatly appreciated.

    Dim i As Integer
    For i = 6 To 10000

    If ThisWorkbook.Sheets("Dryer Analysis 08").Range("I" + CStr(i)).Value <> "" Then
    Range("A&Cstr(i):K&CStr(i)").Select
    Selection.Copy
    Sheets("Data Summary").Select
    Range("A10000").Select
    Selection.End(xlUp).Select
    ActiveSheet.Paste
End If

If ThisWorkbook.Sheets("Dryer Analysis 08").Range("J" + CStr(i)).Value <> "" Then
    Range("Ai:Ki").Select
    Selection.Copy
    Sheets("Data Summary").Select
    Range("A10000").Select
    Selection.End(xlUp).Select
    ActiveSheet.Paste
End If

If ThisWorkbook.Sheets("Dryer Analysis 08").Range("K" + CStr(i)).Value <> "" Then
    Range("Ai:Ki").Select
    Selection.Copy
    Sheets("Data Summary").Select
    Range("A10000").Select
    Selection.End(xlUp).Select
    ActiveSheet.Paste
End If

    Next i
End Sub

----------


## jeff_e_84

Dim i As Integer
    For i = 6 To 10000

Sheets("Dryer Analysis 08").Select
If ThisWorkbook.Sheets("Dryer Analysis 08").Range("I" + CStr(i)).Value <> "" Then
    Range(Cells(CStr(i), 1), Cells(CStr(i), 11)).Select
    Selection.Copy
    Sheets("Data Summary").Select
    Range("A10000").Select
    Selection.End(xlUp).Select
    ActiveSheet.Paste
End If

Sheets("Dryer Analysis 08").Select
If ThisWorkbook.Sheets("Dryer Analysis 08").Range("J" + CStr(i)).Value <> "" Then
    Range(Cells(CStr(i), 1), Cells(CStr(i), 11)).Select
    Selection.Copy
    Sheets("Data Summary").Select
    Range("A10000").Select
    Selection.End(xlUp).Select
    ActiveSheet.Paste
End If

Sheets("Dryer Analysis 08").Select
If ThisWorkbook.Sheets("Dryer Analysis 08").Range("K" + CStr(i)).Value <> "" Then
    Range(Cells(CStr(i), 1), Cells(CStr(i), 11)).Select
    Selection.Copy
    Sheets("Data Summary").Select
    Range("A10000").Select
    Selection.End(xlUp).Select
    ActiveSheet.Paste
End If

    Next i
End Sub

I got past the Range error.  Now I just need it to copy in the correct place.  It copies every selection into the same row

----------


## jeff_e_84

Got it!  Forgot my .Offset

----------

