Reference a cell range from Row/Col Variables

agroom

Active member
Joined
Sep 14, 2006
Messages
39
Programming Experience
Beginner
I was wondering if there's any easyway (make that any way at all) to reference a range of cells given a row and column variable. I've got a loop that runs through an excel file that formats and writes data, but I need to merge a few cells.

The only current way I know how to reference a range is: ExlObj.Range("A1:A2"), and that works fine, but I don't know how to convert my col/row variables into a string like that.

If anyone know's, could you post a code sample using 'Row' and 'Col' to reference a range?
 
figures, I spend hours searching around for an answer only to find it moments after I post asking for help :p
here's how It works using Row and Col for variables:

Basic Syntax to select a range:
ExlObj.Range([Cell 1], [Cell 2])

Now we replace [Cell 1] and [Cell 2] with a function that breaks them into rows and columns - Cells([row], [col]) :
ExlObj.Range(ExlObj.Cells([Row1], [Col1]), ExlObj.Cells([Row2], [Col2])

Now we replac the [row1], [col1] etc with our Row and Col variables where x and y are the # of rows and columns you want in the range:
ExlObj.Range(ExlObj.Cells(Row, Col), ExlObj.Cells(Row+x, Col+y))
 
Back
Top