1

I'm trying to copy everything from column A in sheet1 to sheet2. The issue is that it won't be a static range, i.e the numbers of rows in column A isn't constant. Below is what I'm using that works for 100 rows, how would I change it to work for x rows? Thanks very much in advance.

Sheets("Sheet2").Range("A2:A102").Value = Sheets("Sheet1").Range("A5:A105").Value
Community
  • 1
  • 1

1 Answers1

0

Try this one:

x = 100
Sheets("Sheet2").Range("A2").Resize(x).Value = _
            Sheets("Sheet1").Range("A5").Resize(x).Value

if you want to use last used row instead x, look into this answer: How to determine last used row/column

Community
  • 1
  • 1
Dmitry Pavliv
  • 35,333
  • 13
  • 79
  • 80