Is it possible to use the Range() property with a variable as an input? I'm trying to use it with fixed columns but variable rows.
Essentially, I'm trying to copy rows with values from one sheet and insert them into another. The number of rows with values that I'm copying varies. Here's my code:
Code
Dim RowCount As Long
Dim x As Long
x = 0
RowCount = 1
'x is variable that will end the loop
Sheets("Sheet1").Select
Do While x = 0
If Cells(RowCount, 1) = "" Then
x = 1
'Ends the loop. We reached a row with no value
Else
RowCount = RowCount + 1
'There's a value. Move to the next row
End If
Loop
'After the loop, RowCount should equal the bottom row of the value. Now, we want to copy rows 1 through (RowCount - 1) and insert them into another sheet
' I need to copy the rows from 1 to (RowCount - 1), however I can't figure out how to use the Range() property combined with the variable RowCount to selec the range I need to copy. I've tried using the Cells property but cannot Select a range of cells to copy with that property.
Display More
Range("A"1:"E"RowCount) obviously does not work...
Thanks!