+ Reply to Thread
Results 1 to 13 of 13

Macros - adding number to specific names

Hybrid View

  1. #1
    Registered User
    Join Date
    10-17-2014
    Location
    Ljubljana
    MS-Off Ver
    2010
    Posts
    6

    Macros - adding number to specific names

    Hi,
    i want to make a macro, that adds numbers in order from 1 to the end of the list, but for the same name, the same number. I have added an example in link bellow.
    Can anyone please help me find the solution? Sorry about my bad english. If you need additional informations, just say.

    http://shrani.si/f/14/Ev/2SDFCx1q/tabel.jpg

    I appreciate for any help in advice.

  2. #2
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Macros - adding number to specific names

    Are you wanting to reuse this macro or just have it create the numbers on some worksheet you're using? if its a one off then in Column A add the following into A2
    =if(B2=B1,A1,A1+1)

    then drag it down the length of your sheet.

  3. #3
    Valued Forum Contributor Kamboj's Avatar
    Join Date
    09-25-2014
    Location
    India
    MS-Off Ver
    2003 - 2010
    Posts
    430

    Re: Macros - adding number to specific names

    Please explain your query in attached sheet

  4. #4
    Registered User
    Join Date
    10-17-2014
    Location
    Ljubljana
    MS-Off Ver
    2010
    Posts
    6

    Re: Macros - adding number to specific names

    I need to use this macro on different worksheets, few times a month. I have tried with =if(B2=B1,A1,A1+1) but it`s not working or I didn`t make it right. It says: The formula you typed contains an error.

    Kamboj
    I manually insert a column A, than I need to insert numbers in column A. Each name in column B must have the same number. The numbers must be created in order. The lenght of the list is every time different.

  5. #5
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Macros - adding number to specific names

    the formula is correct, I forgot to mention that in A1 you should put the number 1 so that A2 knows what to do next.

  6. #6
    Registered User
    Join Date
    10-17-2014
    Location
    Ljubljana
    MS-Off Ver
    2010
    Posts
    6

    Re: Macros - adding number to specific names

    I stil can`t figure it out, what am I doing wrong :S
    First row is header row, so I put number 1 in A2. than I put =if(B2=B1,A1,A1+1) in A2?
    Sorry for confusion.

  7. #7
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Macros - adding number to specific names

    My bad.

    In A2 put the number 1
    In A3 put the formula =if(B3=B2,A2,A2+1)

    Double click the bottom right of Cell A3 to populate all the required cells below or drag the cell down as far as you need.

  8. #8
    Registered User
    Join Date
    10-17-2014
    Location
    Ljubljana
    MS-Off Ver
    2010
    Posts
    6

    Re: Macros - adding number to specific names

    I still get an error message. And I did exactly like you said.
    In A2 put a number 1, in A3 put if formula, hit enter and get the error message.

  9. #9
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Macros - adding number to specific names

    can you add your spreadsheet to this so I can see it? what exactly does the error say?

  10. #10
    Registered User
    Join Date
    10-17-2014
    Location
    Ljubljana
    MS-Off Ver
    2010
    Posts
    6

    Re: Macros - adding number to specific names


  11. #11
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Macros - adding number to specific names

    I have to admit Im lost, that definitely looks correct and Ive just tested the formula and it works fine here. Can you create a new sheet with just a dozen or so test items in and apply the formula there to see if its something to do with the workbook itself?

  12. #12
    Registered User
    Join Date
    10-17-2014
    Location
    Ljubljana
    MS-Off Ver
    2010
    Posts
    6

    Re: Macros - adding number to specific names

    Ok I think I finally did it! Instead of , you have to put ;


    Thanks again for all you help!
    Take care

  13. #13
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Macros - adding number to specific names

    very strange because you definitely have to use , in an IF statement?

+ 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] Adding the names of all macros in current workbook into a combobox
    By lordterrin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-05-2013, 11:17 AM
  2. Adding 1 of 2 numbers to a cell to get a specific number
    By pleasesmile in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-30-2013, 09:05 PM
  3. Formula for adding a date to a specific number
    By Riggs18 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 04-16-2013, 03:54 PM
  4. Adding data from specific names ugh!!
    By jayclinton in forum Excel General
    Replies: 5
    Last Post: 12-17-2008, 11:45 PM
  5. Adding numbers from specific cells in a number of sheets
    By c991257 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-03-2006, 05:43 PM

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