ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Creating a range name from Selection.CurrentRegion.Select (https://www.excelbanter.com/excel-programming/426513-creating-range-name-selection-currentregion-select.html)

Rich

Creating a range name from Selection.CurrentRegion.Select
 
I have a user who tracks his time in Excel. He recorded a macro which sorts
the worksheet according to job number.

But, he wants the macro to work with any of his worksheets within any
workbook. Therefore, I changed the beginning of the lines in the macro to:
ActiveSheet instead of a specific sheet.

Then, I have the macro move the active cell cursor to A1 and do a
"Selection.CurrentRegion.Select", which selects the region. Next, I want to
name the range.

However, when I do that, I'm coming up with a boolean. This does me no good,
since I want to use the NamedRange to tell the sort command what to sort.

How can I convert the command, "Selection.CurrentRegion.Select" to a Named
Range?

Thank you for any help!

Dave Peterson

Creating a range name from Selection.CurrentRegion.Select
 
selection.currentregion.name = "somenamehere"


Rich wrote:

I have a user who tracks his time in Excel. He recorded a macro which sorts
the worksheet according to job number.

But, he wants the macro to work with any of his worksheets within any
workbook. Therefore, I changed the beginning of the lines in the macro to:
ActiveSheet instead of a specific sheet.

Then, I have the macro move the active cell cursor to A1 and do a
"Selection.CurrentRegion.Select", which selects the region. Next, I want to
name the range.

However, when I do that, I'm coming up with a boolean. This does me no good,
since I want to use the NamedRange to tell the sort command what to sort.

How can I convert the command, "Selection.CurrentRegion.Select" to a Named
Range?

Thank you for any help!


--

Dave Peterson

Rich

Creating a range name from Selection.CurrentRegion.Select
 
Thanks Dave . . .

Of course, I was able to answer my own question with the following:

RngName = ActiveSheet.Range("A1").CurrentRegion.Address
'Selection.CurrentRegion.Select
ActiveWorkbook.Names.Add Name:="TestName", RefersToR1C1:=RngName

Thanks though . . . you pointed me what should have been an obvious answer
(but wasn't to me!).

Rich

"Dave Peterson" wrote:

selection.currentregion.name = "somenamehere"


Rich wrote:

I have a user who tracks his time in Excel. He recorded a macro which sorts
the worksheet according to job number.

But, he wants the macro to work with any of his worksheets within any
workbook. Therefore, I changed the beginning of the lines in the macro to:
ActiveSheet instead of a specific sheet.

Then, I have the macro move the active cell cursor to A1 and do a
"Selection.CurrentRegion.Select", which selects the region. Next, I want to
name the range.

However, when I do that, I'm coming up with a boolean. This does me no good,
since I want to use the NamedRange to tell the sort command what to sort.

How can I convert the command, "Selection.CurrentRegion.Select" to a Named
Range?

Thank you for any help!


--

Dave Peterson



All times are GMT +1. The time now is 03:18 AM.

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