+ Reply to Thread
Results 1 to 7 of 7

Naming an Excel Range for the entire active sheet

  1. #1
    Registered User
    Join Date
    07-20-2017
    Location
    US
    MS-Off Ver
    2013
    Posts
    15

    Naming an Excel Range for the entire active sheet

    Searched high and low and can't quite get this right.

    Looking for a macro that names all cells as "Table9" --> But I want it as a range, not as a table.
    The number of rows will change day over day, but the columns are fixed at 20.

    Thank you in advance.

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Naming an Excel Range for the entire active sheet

    This code will easily adapt to your situation.... What I didn't get from you is sheet name, starting column/row, and whether the last row is intended to be the "bottom" of the data on the sheet.... I assumed that you do want the last row with data, code currently uses col A to calculate that:

    Please Login or Register  to view this content.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Naming an Excel Range for the entire active sheet

    You don't need VBA for this - use a dynamic named range instead.

    Go to the Name Manager, add a new name ('Table9') and in the 'Refers To' field add: =OFFSET($A$1,0,0,COUNTA($A:$A),20)

    That will adjust automatically as data is added to Col A.

  4. #4
    Registered User
    Join Date
    07-20-2017
    Location
    US
    MS-Off Ver
    2013
    Posts
    15

    Re: Naming an Excel Range for the entire active sheet

    This is like 99% there. The purpose of this is I'm bringing in an external worksheet everyday, so the sheet name changes each day - and it's really unpredictable.

    So where you have 'Set ws = Worksheets("Sheet1") <--I need that Sheet1 just to be the ActiveSheet... Is that possible?

  5. #5
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Naming an Excel Range for the entire active sheet

    Yes...
    Please Login or Register  to view this content.
    Cytop's suggestion is also a very good option..., though if the sheet name is variable too, and you really need the activesheet, then that may not work as well. (Which we didn't know when he made his suggestion)
    Last edited by Arkadi; 07-21-2017 at 09:29 AM.

  6. #6
    Registered User
    Join Date
    07-20-2017
    Location
    US
    MS-Off Ver
    2013
    Posts
    15

    Re: Naming an Excel Range for the entire active sheet

    Worked like a charm - Thank you all!

  7. #7
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Naming an Excel Range for the entire active sheet

    Thanks for the rep
    Could I ask you to also mark the thread as solved when you have a moment please? Thanks in advance!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Send selected cells in email not entire active sheet
    By markhopcraft in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-02-2015, 12:11 PM
  2. Replies: 3
    Last Post: 07-16-2015, 09:29 AM
  3. [SOLVED] save active sheet in new workbook, naming it as cell value of active sheet
    By arkharova.s in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-18-2014, 06:16 AM
  4. Replies: 20
    Last Post: 01-11-2014, 05:39 AM
  5. [SOLVED] Insert Row under cell containing text on entire active sheet
    By mgeddes in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 11-04-2013, 07:04 AM
  6. Naming an embedded image while it is being added to the active sheet
    By schmidt1962 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-01-2013, 10:15 AM
  7. [SOLVED] Naming Range Different Sheet
    By pezalmendra in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-18-2013, 04:32 PM

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