+ Reply to Thread
Results 1 to 6 of 6

Dynamic name

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-23-2012
    Location
    tehran,iran
    MS-Off Ver
    Excel 2010
    Posts
    179

    Dynamic name

    Hi there
    I have an Excel file which update every day
    for example : range A1:F12 filling by data today
    tomorrow my range will be extended to A1:F28 and the day after A1:F39 and again and again
    now could you please show me how I can define a range name for that ?

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Dynamic name

    Hi, pedjvak,

    easiest way would be to use a Table which would auto update to the number of cells filled.

    Dim lngLast As Long
    lngLast = Range("A" & Rows.Count).End(xlUp).Row
    MsgBox "Range for today covers 'A1:F" & lngLast & "'", vbInformation
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Contributor
    Join Date
    06-23-2012
    Location
    tehran,iran
    MS-Off Ver
    Excel 2010
    Posts
    179

    Re: Dynamic name

    Dear HaHoBe
    could you plz write your solution completely because I am new in excel
    thanks

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Dynamic name

    Hi, pedjvak,

    if you had indicated what you need that information for IŽd done it in my first post.

    Sub EF965621_1()
    'Display range in MsgBox
    'always works on the active sheet
    Dim lngLast As Long
    lngLast = Range("A" & Rows.Count).End(xlUp).Row
    MsgBox "Range for today covers 'A1:F" & lngLast & "'", vbInformation
    End Sub
    Sub EF965621_2()
    'Copy the range to the clipboard
    'always works on the active sheet
    Range("A1:F" & Range("A" & Rows.Count).End(xlUp).Row).Copy
    End Sub
    How to install your new code
    1. Copy the Excel VBA code
    2. Select the workbook in which you want to store the Excel VBA code
    3. Press Alt+F11 to open the Visual Basic Editor
    4. Choose Insert > Module
    5. Edit > Paste the macro into the module that appeared
    6. Close the VBEditor
    7. Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

    To run the Excel VBA code:
    1. Press Alt-F8 to open the macro list
    2. Select a macro in the list
    3. Click the Run button
    Ciao,
    Holger

  5. #5
    Valued Forum Contributor ratcat's Avatar
    Join Date
    03-07-2008
    Location
    Rural NSW, Australia
    MS-Off Ver
    Vista 2007
    Posts
    1,111

    Re: Dynamic name

    Last edited by ratcat; 11-02-2013 at 05:25 AM.
    Have I made you happy ??? If yes, please make me happy by pressing the http://www.excelforum.com/images/buttons/reputation-40b.png Add Reputation button in my post.
    Please don't forget to do the same to other contributors of this forum.

    Thanks
    I don't void confusion, I create it

  6. #6
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Dynamic name

    A1:INDEX(F:F,COUNTA(A:A)) wound generate a dynamic named range based on the length of data in column a no spaces allowed
    or maybe
    A1:INDEX(F:F,LOOKUP(2,1/(A1:A60000<>""),ROW(A1:A60000))
    use like
    =INDEX(A1:INDEX(F:F,LOOKUP(2,1/(A1:A60000<>""),ROW(A1:A60000))),MATCH(H1,A1:A60000,0),6)
    or
    =COUNTIF(A1:INDEX(F:F,LOOKUP(2,1/(A1:A60000<>""),ROW(A1:A60000))),"z")
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

+ 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. Dynamic Range Column Chart w/ Dynamic Avg Line (Excel 2007)
    By BrokenBiker in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 10-04-2012, 11:40 AM
  2. Replies: 0
    Last Post: 02-28-2006, 09:10 PM
  3. Replies: 0
    Last Post: 02-28-2006, 09:10 PM
  4. Replies: 0
    Last Post: 02-28-2006, 09:10 PM
  5. Replies: 2
    Last Post: 02-02-2006, 04:10 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