G
George Boynton
I have a problem with this statement: myrow =
Range("A1").CurrentRegion.Rows.Count + 1,
or as an alternative myrow = Range("A1").End(xlDown).Row + 1, when the
number of rows of data on a worksheet changes. My goal, using this
variable, is to determine the row number of the line just below the last
line of data.
Assume a worksheet with 10 rows of data with cell A1 included in the first
row of data. myrow = 11, and both of the two expressions just mentioned
will also evaluate to 11. That's great so far.
Assume later in the procedure some code adds 10 more rows of data starting
at row 11, increasing the total number of rows of data to 20. At this point
I have found that myrow still equals 11 while either of the two expressions
now evaluate to 21, the correct number. If subsequently, more rows of data
are added, the value of myrow remains constant at 11 while
Range("A1").CurrentRegion.Rows.Count or Range("A1").End(xlDown).Row + 1
will evaluate again to the correct number.
Why is the variable myrow acting like a constant? Note in my declarations I
did not precede myrow with "Const". How can I get myrow to act like a
variable?
Thanks.
Range("A1").CurrentRegion.Rows.Count + 1,
or as an alternative myrow = Range("A1").End(xlDown).Row + 1, when the
number of rows of data on a worksheet changes. My goal, using this
variable, is to determine the row number of the line just below the last
line of data.
Assume a worksheet with 10 rows of data with cell A1 included in the first
row of data. myrow = 11, and both of the two expressions just mentioned
will also evaluate to 11. That's great so far.
Assume later in the procedure some code adds 10 more rows of data starting
at row 11, increasing the total number of rows of data to 20. At this point
I have found that myrow still equals 11 while either of the two expressions
now evaluate to 21, the correct number. If subsequently, more rows of data
are added, the value of myrow remains constant at 11 while
Range("A1").CurrentRegion.Rows.Count or Range("A1").End(xlDown).Row + 1
will evaluate again to the correct number.
Why is the variable myrow acting like a constant? Note in my declarations I
did not precede myrow with "Const". How can I get myrow to act like a
variable?
Thanks.