+ Reply to Thread
Results 1 to 16 of 16

Number rows based on content on another column

  1. #1
    Registered User
    Join Date
    04-20-2013
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    96

    Number rows based on content on another column

    Hi,

    I'm trying to get this code to work, but can't figure out what's wrong with it. I'm trying to number rows on column A (starting on A2), based on how many rows have content on column B. I tried the codes below using both Excel 2010 & 2016, but nothing happens. No error message, no numbers entered.

    What am I missing? Is there a better option rather than using Autofill?

    Thanks for any help!

    Please Login or Register  to view this content.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,047

    Re: Number rows based on content on another column

    I think you would do better to upload a small sample of what you have - and what you want
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Number rows based on content on another column

    Hello axtryo,

    Use the Code below;

    Please Login or Register  to view this content.
    Regards.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  4. #4
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Number rows based on content on another column

    Hi axtryo,

    If you prefer to see values only, then please use the Code below;

    Please Login or Register  to view this content.
    Regards.
    Attached Files Attached Files
    Last edited by Winon; 03-06-2017 at 10:07 AM. Reason: Changed Code

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Number rows based on content on another column

    Another:

    Please Login or Register  to view this content.

  6. #6
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Number rows based on content on another column

    @ JOHN H. DAVIS,

    Why do you count Blank Cells in Column B?

    Man, if I get hold of you!

    Kind Regards.

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Number rows based on content on another column

    @ Winon. Oops.

    Please Login or Register  to view this content.
    Last edited by JOHN H. DAVIS; 03-06-2017 at 12:40 PM.

  8. #8
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Number rows based on content on another column

    @ JOHN H. DAVIS,

    Almost there Dear John,

    To avoid a dear johnny letter, please ensure your Code provides a logical numerical sequence. For instance, with Cells 8 and 9 in Column B being empty, the next value in Column A should be 8 and not 10.

    I like your Loop approach, but before I award you with any points, I would like to see how you come up with a magical "Fix".LOL

    Thank you my friend.

  9. #9
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Number rows based on content on another column

    @ Winon: Post No. 7 was edited, does it not accomplish what you mention in Post No.8?

  10. #10
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Number rows based on content on another column

    @ JOHN H. DAVIS,

    Hi John,

    Sorry, no, I did not see your edited Code.

    Absolutely Brilliant! You Passed with flying colors!

    Well done my Friend.

    Kind Regards.

  11. #11
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Number rows based on content on another column

    Hi axtryo,

    JOHN H. DAVIS came up with an excellent piece of Code, and I have put it all together for you in the attached "Automated" sample Workbook.

    Column A will update automatically if you add or delete any Data in Column B.

    Please say thank you to John for his great contribution.

    Regards.
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    04-20-2013
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    96

    Re: Number rows based on content on another column

    Well,

    Winon and John Davis ... Saying 'thanks' sounds way short of the gratitude I feel. For people like me who only have a basic understanding of VBA, having other like you both offering help, goes beyond a simple thanks. Yet, I really appreciate the time you both invested in helping me solve this issue.

    You both made my day!

  13. #13
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Number rows based on content on another column

    Hello
    I know that this is solved but this is my try
    Please Login or Register  to view this content.
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  14. #14
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Number rows based on content on another column

    Hi axtryo,

    I have revised the sample Workbook in Post# 11, to work much better.

    Please see the attachment.

    Regards.
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    04-20-2013
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    96

    Re: Number rows based on content on another column

    Hi all,

    Thank you so much for helping me solve this. Since I got the code working, I'm now marking this post as solved.

    Thanks again!

  16. #16
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Number rows based on content on another column

    You are welcome axryo, glad we could help.

    Thanks for the "Rep", Much appreciated.

    Regards.

+ 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] Need a formula to copy rows based on content of one column
    By gasdesign in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-12-2016, 01:57 AM
  2. change number format based on content of another column using vba
    By Declamatory in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-17-2014, 10:51 AM
  3. distribute rows based on column content
    By melody10 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-17-2014, 12:04 PM
  4. Use VBA to delete netire rows based on content of one column
    By Jemwig in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-20-2013, 04:53 PM
  5. Replies: 1
    Last Post: 05-09-2011, 11:34 AM
  6. Replies: 0
    Last Post: 02-02-2011, 06:42 PM
  7. Selecting a number of rows based on the content
    By matpj in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-25-2005, 05:30 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