+ Reply to Thread
Results 1 to 4 of 4

Numbering macro

  1. #1
    Registered User
    Join Date
    12-02-2022
    Location
    Earth
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    3

    Numbering macro

    Dear all,

    I am new to this forum, which helped me many many times in the past - so thanks to all contributors for their amazing job.

    Nevertheless, I couldn't find a solution to an issue that seems easy at first sight :D.

    I am trying to create a macro which would allow me to put sequential numbering in an excel sheet I am building. The idea of this macro is to put the "Level 1" number on column A (e.g., 1, 2, 3,...) and the "Level 2" in column B (e.g., 1.1., 1.2., 2.1., 2.2., 2.3., etc.).

    By googling and researching I could find a way of dealing with such issue using names, whereas names are defined as follow (supposing the Level1 number is put in cell A13 and Level2 in cell B18):

    Level1 = IF(COUNTA(Sheet1!$A$1:$A12)=0,0,INDEX(Sheet1!$A$1:$A12,MATCH(ROW(Sheet1!$A12), Sheet1!$A$1:$A12,TRUE)))+1
    Level2 = Book1!Level1-1&"."&MAX(1,COUNTA(INDEX(Sheet1!$B$1:$B17,MATCH(Book1!Level1-1,Sheet1!$A$1:$A17,FALSE)):Sheet1!$B17))

    The problems I am encountering are the following:

    1. If I create a new sheet from scratch, I'd have to insert the names defined above every time
    2. If I duplicate I sheet in a given file, then the names are duplicated as well (i.e., I will have names for Sheet1, Sheet2, etc.)

    As such, I am trying to build up a macro allowing me to create such numbering without creating duplicate names and allowing me to use it in other workbooks independently.

    I hope having put all necessary inputs and that someone could help me figure out how to solve such issue.

    Thank you all in advance.

    Kubo

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,426

    Re: Numbering macro

    Please post a link to the example you found. You may have to break it up using spaces as you are a new user.


    Fast answers need visual help. Please read the yellow banner at the top of this page on how to attach a file and a mocked up solution.

    Please show what result you hope to get with several rows of information.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    12-02-2022
    Location
    Earth
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    3

    Re: Numbering macro

    I am attaching a file showing the expected result.

    For the time being, the numbering is built using named ranges. So, if a start a file from scratch I always have to write down these numbering formulae. Another problem with this approach is that once a tab is duplicated, the named ranges are duplicated as well... ;/

    Aim eventually is to have a macro instead (if possible) as the idea will be to have a button in the ribbon which allows me to put the numbering as requested (level 1 and level 2).

    Hope this helps. Thank you a lot.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    12-02-2022
    Location
    Earth
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    3

    Re: Numbering macro

    Maybe there is already a thread in this forum which I could not find - happy to be redirected if there is one

+ 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. [SOLVED] WBS macro: re-numbering if new project
    By Remphan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-23-2020, 11:28 AM
  2. [SOLVED] Macro for numbering sequence
    By jackyung in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-01-2019, 10:48 PM
  3. Multi level reference id - auto numbering - similar to legal numbering
    By smsko in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 12-11-2017, 06:05 AM
  4. Do Until Numbering Macro
    By barrsm0 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-24-2015, 06:14 PM
  5. Replies: 2
    Last Post: 06-27-2014, 06:40 AM
  6. [SOLVED] macro for Sorting & then Numbering
    By santosh226001 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-10-2013, 03:59 AM
  7. numbering macro
    By Maasha in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 11-22-2005, 03:25 AM

Tags for this Thread

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