+ Reply to Thread
Results 1 to 3 of 3

Assigning name to current region

  1. #1
    KDJ
    Guest

    Assigning name to current region

    Hello

    After selecting the current region, I would like to assign the name
    Total_Statistic. The region can change and the name should be overwritten
    each time I run the macro.

    I am selecting the region as follows:

    Set tbl = ActiveCell.CurrentRegion
    tbl.Select

    I can't find the right VBA command to assign a name, given that this isn't a
    cell reference. Would really appreciate some help!
    --
    Thanks very much. KDJ

  2. #2
    Norman Jones
    Guest

    Re: Assigning name to current region


    Hi KDJ,

    Try something like:

    Public Sub Tester03a()
    Dim tbl As Range

    Set tbl = ActiveCell.CurrentRegion()

    ActiveWorkbook.Names.Add _
    Name:="Total_Statistic", _
    RefersTo:=tbl
    End Sub

    ---
    Regards,
    Norman



    "KDJ" <[email protected]> wrote in message
    news:[email protected]...
    > Hello
    >
    > After selecting the current region, I would like to assign the name
    > Total_Statistic. The region can change and the name should be overwritten
    > each time I run the macro.
    >
    > I am selecting the region as follows:
    >
    > Set tbl = ActiveCell.CurrentRegion
    > tbl.Select
    >
    > I can't find the right VBA command to assign a name, given that this isn't
    > a
    > cell reference. Would really appreciate some help!
    > --
    > Thanks very much. KDJ




  3. #3
    KDJ
    Guest

    Re: Assigning name to current region

    Thanks again, Norman ... you've saved my Monday

    KDJ


    "Norman Jones" schrieb:

    >
    > Hi KDJ,
    >
    > Try something like:
    >
    > Public Sub Tester03a()
    > Dim tbl As Range
    >
    > Set tbl = ActiveCell.CurrentRegion()
    >
    > ActiveWorkbook.Names.Add _
    > Name:="Total_Statistic", _
    > RefersTo:=tbl
    > End Sub
    >
    > ---
    > Regards,
    > Norman
    >
    >
    >
    > "KDJ" <[email protected]> wrote in message
    > news:[email protected]...
    > > Hello
    > >
    > > After selecting the current region, I would like to assign the name
    > > Total_Statistic. The region can change and the name should be overwritten
    > > each time I run the macro.
    > >
    > > I am selecting the region as follows:
    > >
    > > Set tbl = ActiveCell.CurrentRegion
    > > tbl.Select
    > >
    > > I can't find the right VBA command to assign a name, given that this isn't
    > > a
    > > cell reference. Would really appreciate some help!
    > > --
    > > Thanks very much. KDJ

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1