Results 1 to 5 of 5

Excel vba - Loop thru a dynamic range, Find value does not go beyond second found value.

Threaded View

Trompie Excel vba - Loop thru a... 04-02-2014, 07:12 PM
6StringJazzer Re: Excel vba - Loop thru a... 04-02-2014, 09:39 PM
Trompie Re: Excel vba - Loop thru a... 04-02-2014, 10:16 PM
AlphaFrog Re: Excel vba - Loop thru a... 04-02-2014, 10:41 PM
Trompie Re: Excel vba - Loop thru a... 04-03-2014, 12:19 AM
  1. #1
    Registered User
    Join Date
    05-17-2012
    Location
    Gold Coast, Australia
    MS-Off Ver
    Excel 2007
    Posts
    39

    Excel vba - Loop thru a dynamic range, Find value does not go beyond second found value.

    Hi,
    I have a range of cells in a column which changes with new data.
    Code selects the range to last cell in column with value +1.

    Some of the cells in the range SUM the totals of the cells above (number of cells vary from 1 to many rows).

    Code then finds first cell with "Sum" in formula, offsets to cell on left and inserts formula.
    Loops back to do second pass.
    That works fine.
    Selects next Cell with "Sum" in Formula,offsets to cell on left and inserts formula.
    That works fine.
    Up to here there is no issue.
    From here on though I cannot get the code to move down to the next "Sum" (there may be many) until the last cell in the Range (that was selected in the first place).

    Clearly I have a syntax error and some missing code requirement!

    Can anyone help?

    Here is the code I have so far :

    Sub LastCellInColumnOffsetInsert()
            
            Dim foundCount As Long
            Dim RR As Range
            Set RR = Range("I1:I" & Range("I" & Rows.count).End(xlUp).Row)
            RR.Select
        
        Set dynamicRange = Range("I2").CurrentRegion
        For Each cell In RR.Cells
            With RR.Find(What:="sum", _
                        After:=ActiveCell, _
                        LookIn:=xlFormulas, _
                        LookAt:=xlPart, _
                        SearchOrder:=xlByColumns, _
                        SearchDirection:=xlNext, _
                        MatchCase:=False, _
                        SearchFormat:=False).Activate
                     ActiveCell.Offset(0, -1).Select
                        ActiveCell.FormulaR1C1 = "=CONCATENATE(R[-1]C[-7]:R[-1]C[-7],""  "",""TOTAL"")"
         End With
                    ActiveCell.Offset(1, 1).Activate
               	 Cells.FindNext.Select
        
        Next
        End Sub
    Last edited by Trompie; 04-02-2014 at 10:15 PM. Reason: Forum rule 7

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. loop to find integers and decimals and pass found row to bookmark code.
    By beenbee in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-17-2014, 08:00 AM
  2. Loop through Column to find decimal then pass found row to bookmark code
    By beenbee in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-11-2014, 11:13 AM
  3. [SOLVED] nested loop for copying range: error no cells were found
    By Edejager in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-09-2013, 08:52 AM
  4. Dynamic Range using Offset, range not found for Pivot
    By GoneBaja in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-08-2012, 09:19 AM
  5. How to exit a loop once the value is found in the range
    By Suety in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-28-2010, 01:30 PM

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