+ Reply to Thread
Results 1 to 4 of 4

Line Numbers needed

Hybrid View

  1. #1
    Registered User
    Join Date
    11-06-2007
    Location
    Illinois
    Posts
    2

    Line Numbers needed

    Hi. I have a form that needs line numbers in column A for only the rows that have data in them; if B6 <> "". I'm using Excel 2002 and a stored procedure to bring in the data from a PSql database. The data actually starts on row 6 in sheet1, so I can't just use the grid row numbers. I've tried everything I can think of to just add an integer to populate the line number column, but, when I do it I get 65536 rows populated instead of the 237 that I need. I know there is probably a very simple way to do this, but I can't seem to find it. I'm an old Cobol programmer and this has me stumped.

    Thanks for any help
    Cathy

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    maybe this will help

    Dim rng    As Range
        Dim cl     As Range
    
        Set rng = Range(Cells(6, 2), Cells(Rows.Count, 2).End(xlUp))
        For Each cl In rng
            If Not IsEmpty(cl) Then cl.Offset(0, -1).Value = cl.Row - 5
        Next cl
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    would putting =COUNTA(B$5:B6) in A6 and filling down do what you want?

  4. #4
    Registered User
    Join Date
    11-06-2007
    Location
    Illinois
    Posts
    2

    Talking Thanks!!!

    Thanks Roy. It works!!! I really appreciate the help. And Mike, I tried that and it worked great until I initialized the cells with a clear contents for the next query, then it wiped out the Count formula.

    Thanks again to both of you for your fast replys!!
    Cathy

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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