PC Review


Reply
Thread Tools Rate Thread

Creating a range name from Selection.CurrentRegion.Select

 
 
Rich
Guest
Posts: n/a
 
      6th Apr 2009
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!
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      6th Apr 2009
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
 
Reply With Quote
 
Rich
Guest
Posts: n/a
 
      6th Apr 2009
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
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error with Selection.CurrentRegion.Rows.Count? KenY Microsoft Excel Programming 2 21st Apr 2010 11:01 AM
Range(Selection, Selection.End(xlToRight)).Select =?Utf-8?B?RGF2ZSBCaXJsZXk=?= Microsoft Excel Programming 2 6th Jun 2007 04:53 PM
How to select the bottom right cel in a 'CurrentRegion.selecion' Luc Microsoft Excel Programming 3 3rd Mar 2007 07:58 PM
Select first row of currentregion vba Microsoft Excel Programming 4 19th Jul 2006 01:16 PM
Select a range in a column in currentregion ward376 Microsoft Excel Programming 6 14th Mar 2006 02:25 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:29 AM.