0

I am trying to copy a range of cells from one sheet to another. It searches for an empty column, then copies the current data. However, it will not compile and fails at

Sheets("Archive").Range(Cells(2, x), Cells(100, x)).Value = Sheets("Main").Range("H2:H100").Value

The full code is:

Sub Generate()
Dim i As Boolean
Dim x As Long
i = False
x = 2
Do While i = False
    If Sheets("Archive").Cells(2, x) = "" Then
    i = True
Sheets("Archive").Range(Cells(2, x), Cells(100, x)).Value = Sheets("Main").Range("H2:H100").Value    
MsgBox "Done!"
End If
    x = x + 1
    'debug
    MsgBox "Iteration " & x
Loop     
Sheets("Main").Range("H2:H100").Value = Sheets("Password Generator").Range("A2:A100").Value
Sheets("Main").Range("I2:I100").Value = Sheets("Password Generator").Range("B2:B100").Value

End Sub
  • 2
    **EVERY** Range object needs to be assigned to a parent sheet `Sheets("Archive").Range(Sheets("Archive").Cells(2, x), Sheets("Archive").Cells(100, x)).Value...` – Scott Craner May 24 '17 at 18:12
  • Thank you very much. I searched SO for a solid hour before making an account. Sorry about the duplicate. – Colby Raynor May 24 '17 at 18:26

0 Answers0