Quick VBA question - defining cell range
Posted on 2007-08-07
I have quick question in VBA programming. How do we select cell ranges when both the row range and column range are variables whose values are obtained from the program before it.
For example, if we want to auto fit ranges from B2 to E7, the code will be
However, the indices could change for the next worksheet we apply the code to. It could change to, say, C3:D8. The variable keep track of those row and column indices are ci, cj for begin and end column, ri, rj for begin and end row. Now that, if we do know ci, cj, ri, rj, what will be the code look like?
Will it be
range(indirect("ciri,cjrj")) ? it does not seem to work.