+ Reply to Thread
Results 1 to 4 of 4

Find "x", count up and store # of rows

Hybrid View

ker9 Find "x", count up and store... 11-22-2010, 02:35 PM
ker9 Re: Find "x", count up and... 11-22-2010, 04:20 PM
ker9 Re: Find "x", count up and... 11-22-2010, 04:53 PM
StephenR Re: Find "x", count up and... 11-22-2010, 04:59 PM
  1. #1
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Find "x", count up and store # of rows

    How would I write something that would

    Do Loop

    start at bottom (xlend) and work up

    Find "GroupChange" in column N (0,14)

    Count rows UP to next "GroupChange and store number
    (can store it in column O on same line as found GroupChange)

    Maybe insert a blank row after GroupChange to insert formula that uses that number of rows (sum up x rows)

    until it can't find it

    Thanks!
    Last edited by ker9; 11-22-2010 at 04:54 PM.

  2. #2
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Find "x", count up and store # of rows

    This code works, but inserts hard coded number, where I'd like formula

    It sums up to next blank cell (active cell is blank and receives sum total)
    ActiveCell.Value = WorksheetFunction.Sum(Range(ActiveCell.Offset(-1, 0), ActiveCell.Offset(-1, 0).End(xlUp)))


    This doesn't work, anyone know how to make it work?
    ActiveCell.FormulaR1C1 = "=Sum(Range(ActiveCell.Offset(-1, 0), ActiveCell.Offset(-1, 0).End(xlUp)))"
    Thanks!

  3. #3
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Find "x", count up and store # of rows

    I figured it out - for anyone interested:

    Dim rFind As Range, sAddr As String
     
    With Sheets("Data").UsedRange.Columns(15)
        Set rFind = .Find(What:="GroupChange", LookAt:=xlWhole, MatchCase:=False, SearchFormat:=False)
        If Not rFind Is Nothing Then
            sAddr = rFind.Address
            Do
                    rFind.Offset(-1, -9).Formula = "=SUM(" & rFind.Offset(-2, -9).Address(0, 0) & ":" & rFind.Offset(-2, -9).End(xlUp).Address(0, 0) & ")"
                 Set rFind = .FindNext(rFind)
             Loop While rFind.Address <> sAddr
        End If
    End With
    End Sub

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

    Re: Find "x", count up and store # of rows

    Thank you for posting your solution. That code looks familiar...

+ 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