+ Reply to Thread
Results 1 to 7 of 7

Count the values between range and loop

  1. #1
    Registered User
    Join Date
    11-09-2012
    Location
    Bangalore
    MS-Off Ver
    Excel 2007
    Posts
    16

    Count the values between range and loop

    Folks,
    I have a spreadsheet in which column b has a series of numbers with the heading as "ID". I need a vba code which will count the values between each heading. The data i have on my spreadsheet is till row 2525 with different ranges between heading "ID".

    I have attached the help spreadsheet with the example.

    Appreciate your help.
    Ravi
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Count the values between range and loop

    Try this:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-09-2012
    Location
    Bangalore
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Count the values between range and loop

    Works great! Much appreciate your quick response.

  4. #4
    Registered User
    Join Date
    11-09-2012
    Location
    Bangalore
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Count the values between range and loop

    Works great! Much appreciate your quick response.


    Need 1 more help on the same template.

    Column D will have some number against each EMP ID, what i am looking for is the result in Column E, where in it divides the number against the count within the range. And, if column B is blank it should return me 0 and so on.

    Pls refer the Help2 file for more information.

    Thank you in advance.
    Attached Files Attached Files

  5. #5
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Count the values between range and loop

    Maybe this?
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    11-09-2012
    Location
    Bangalore
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Count the values between range and loop

    Works fine, Thank you Stephen!

  7. #7
    Registered User
    Join Date
    11-09-2012
    Location
    Bangalore
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Count the values between range and loop

    I have one more challenge in the same spreadsheet.

    What i require is Column D (Money) should get calculated based on the column C (Count) and Column F (Type) input.

    With the below code the column C & E is being calculated. Need your help in getting the Column D output. Pls refer the Help 3 spreadsheet for your reference. Thank you!

    ************************


    Sub x()

    Dim rFind As Range, sAddr As String, n As Long

    With Sheet1.Columns(2)
    Set rFind = .Find(What:="ID", LookAt:=xlWhole, MatchCase:=False, SearchFormat:=False)
    If Not rFind Is Nothing Then
    sAddr = rFind.Address
    Do
    n = Range(rFind, rFind.End(xlDown)).Rows.Count - 1
    rFind.Offset(, 1) = n
    rFind.Offset(1, 3).Resize(n) = rFind.Offset(, 2) / n
    Set rFind = .FindNext(rFind)
    Loop While rFind.Address <> sAddr
    End If
    .SpecialCells(xlCellTypeBlanks).Offset(, 3) = 0
    End With

    End Sub
    Attached Files Attached Files

+ 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