ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Select range through Inputbox (https://www.excelbanter.com/excel-programming/424424-select-range-through-inputbox.html)

Bythsx-Addagio[_2_]

Select range through Inputbox
 
Hello,
I am using the below code to prompt the user to select a range of cells. My
problem is that the resulting range is ignoring any workbook reference. If
you select a range on a different workbook it ignores that in the following
function.

How can I capture the absolute reference?

Thanks in advance!

Set varRange = _
Application.InputBox("Select a range of cells:", Type:=8)
If IsObject(varRange) = False Then Exit Sub

RangeAddress = varRange.Address

' Call nested function to return list of unique items
varUniqList = UniqList(Range(RangeAddress))

Peter T

Select range through Inputbox
 
You can capture the full address, like this
RangeAddress = varRange.Address(External:=True)

[BookName]SheetName!$A$1

Note might get additional apostrophes depending on the names

A better way, rather than pass the address, pass the range object. Then you
can work with

rng.Parent.Parent ' the workbook
rng.Parent ' sheet

but you might not need either the above, simply use the range object.

Regards,
Peter T



"Bythsx-Addagio" wrote in message
...
Hello,
I am using the below code to prompt the user to select a range of cells.
My
problem is that the resulting range is ignoring any workbook reference.
If
you select a range on a different workbook it ignores that in the
following
function.

How can I capture the absolute reference?

Thanks in advance!

Set varRange = _
Application.InputBox("Select a range of cells:", Type:=8)
If IsObject(varRange) = False Then Exit Sub

RangeAddress = varRange.Address

' Call nested function to return list of unique items
varUniqList = UniqList(Range(RangeAddress))




joel

Select range through Inputbox
 
Try this change

from:
RangeAddress = varRange.Address
to:
RangeAddress = varRange.Address(External:=True)

"Bythsx-Addagio" wrote:

Hello,
I am using the below code to prompt the user to select a range of cells. My
problem is that the resulting range is ignoring any workbook reference. If
you select a range on a different workbook it ignores that in the following
function.

How can I capture the absolute reference?

Thanks in advance!

Set varRange = _
Application.InputBox("Select a range of cells:", Type:=8)
If IsObject(varRange) = False Then Exit Sub

RangeAddress = varRange.Address

' Call nested function to return list of unique items
varUniqList = UniqList(Range(RangeAddress))



All times are GMT +1. The time now is 09:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com