Consulting

Results 1 to 8 of 8

Thread: Solved: count rows excluding header row

  1. #1

    Red face Solved: count rows excluding header row

    Hi

    I need assistance with code copied from another thread.
    I want to be able to count the amount of rows in a sheet.
    While the below code works i need it to exclude the header row.

    MsgBox Intersect(Range("A:A"),Cells.SpecialCells(xlCellTypeConstants).EntireRow).C ount

    Also need the value in a cell on the spreadsheet and not on a msgbox

    Any assistance appreciated

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Subtract 1?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Sorry i'm a newbie to VBA
    How do i do that

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    MsgBox Intersect(Range("A:A"),Cells.SpecialCells(xlCellTypeConstants).EntireRow).C ount - 1
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5

    Sorry won't forget this one, i thought it would involve complex argument to subtract 1

    Thanks xld

  6. #6
    How can i use the same formula but insert the value in cell and not on a msgbox

  7. #7
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Where would you want it? ...
    [vba]With ActiveSheet
    .Range("A2").Value = Intersect(Range("A:A"),Cells.SpecialCells(xlCellTypeConstants).EntireRow).C ount - 1
    End With[/vba]

    You haven't specified much, but that should do the basics.

    HTH

  8. #8
    Thank you that did the trick

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •