Convert Row/Column to Range

vthokienj

Board Regular
Joined
Aug 1, 2011
Messages
105
Office Version
  1. 365
Platform
  1. Windows
I would think this would be simple, but I have yet to find the solution. If I know the boundaries in row/column format, how do I get this as a range?

So if I know my start is row1/col1 and end is row3/col3, is there a function I can call with the params 1,1,3,3 that would return "A1:C3"?

Thanks
 
I'm not aware of a single worksheet function that would do that.
You could make a User Defined Function (UDF) to do that using VBA.

You could try:
=ADDRESS(1,1)&":"&ADDRESS(3,3)

This isn't a true range reference, but it would work in an INDIRECT formula.
 
Upvote 0
Thanks, I will try that if the next question is not possible.

Could I instead put the range using integers in the Range reference?
My function takes a range, so the following is what currently goes on the
worksheet to reference columns 32 and 33, rows 4-53:

Code:
=myfunc($I1,$AF$4:$AG$53)
I tried to modify on the worksheet to take this form:
Code:
=myfunc($I1,Cells(31,4),Cells(32,53))
or
Code:
=myfunc($I1,Range(Cells(31,4),Cells(32,53)))
Is there simply a way to reformat this function call to use the columns for the range?

Thanks
 
Upvote 0
Here are two ways you could leave your myfunc code unchanged and use Row and Column number values as parameters.

I don't know what your User Defined Function does, but lets use an example UDF that returns a string that includes the Value in the first Cell ($I$1)
and the Address of the second Range.
Code:
Function myfunc(rCell As Range, rRange As Range)
    myfunc = rCell.Value & "---> " & rRange.Address
End Function

Below are formulas that each work using parameters of $I1,$AF$4:$AG$53 from your example.
(The column numbers are actually 32,33 for AF,AG).
Excel Workbook
HI
1Read Me
2
3Using A1 Reference:Read Me---> $AF$4:$AG$53
4
5Using INDIRECT + ADDRESS:Read Me---> $AF$4:$AG$53
6
7Using OFFSET:Read Me---> $AF$4:$AG$53
8
Sheet



The INDIRECT+ADDRESS is probably cleaner than the OFFSET option.

Alternatively, you could change your function declaration to take a Range and four Longs as Parameters. Just ask if you want some help doing that.
 
Upvote 0
One more question about this that I can not find an example of.
How can you specify cells on another worksheet?
I have tried inserting "sheetStuff!" at various points with no luck.

My formula looks like this:
Code:
=myfunc(INDIRECT(ADDRESS(2,2)), INDIRECT(ADDRESS(6,1)&":"&ADDRESS(55,2)))
Cell 2,2 is on the same sheet as the formula, but the cell range is referencng data on another sheet "sheetStuff"

Thanks again for any additional help to this.
 
Upvote 0
The ADDRESS function has some optional parameters:
ADDRESS(row_num,column_num,abs_num,a1,sheet_text)

sheet_text allows you to specify the name of a sheet other than the one the formula is in.

Testing with an example formula, this seems to work....
=myfunc(INDIRECT(ADDRESS(2,2)), INDIRECT(ADDRESS(6,1,,,"sheetStuff")&":"&ADDRESS(55,2)))
 
Last edited:
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top