lrobbo314
Well-known Member
- Joined
- Jul 14, 2008
- Messages
- 3,927
- Office Version
- 365
- Platform
- Windows
Hello,
I use the following method to set ranges in VBA, this code will set the range = A2:Q25 with my data.
I thought that I might be able to condense this code even further but this following line of code results in setting the range to A1 only.
I've tried searching but can't find anything about this.
I know that I can set an integer = the last row in the column, but I am tring to find a way to keep it to one line of code.
I'd just like to know for best practices sake. In the scheme of things I know that that first line is fine.
Thanks for any input.
I use the following method to set ranges in VBA, this code will set the range = A2:Q25 with my data.
Code:
Set r = Range(Range("A2"), Range("Q" & Rows.Count).End(xlUp))
I thought that I might be able to condense this code even further but this following line of code results in setting the range to A1 only.
Code:
Set r = Range("A2:Q" & Rows.Count).End(xlUp)
I've tried searching but can't find anything about this.
I know that I can set an integer = the last row in the column, but I am tring to find a way to keep it to one line of code.
I'd just like to know for best practices sake. In the scheme of things I know that that first line is fine.
Thanks for any input.