Results 1 to 4 of 4

SumIF applied to a dynamic range

Threaded View

  1. #1
    Forum Contributor timtim89's Avatar
    Join Date
    01-05-2012
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Excel 2010
    Posts
    141

    SumIF applied to a dynamic range

    Hey all,

    I hope to apply a SumIF function to a range defined by a few variables (lastRow, lastCol ect.). I prefer the result left in the cells as just the number, but getting the result by applying a formula in the cell will work as well. I have tried a few things, but couldn't make it work, so I really hope someone can help me out. Please see attached file, as it shows better what I need done. Thanks a lot in advance for you effort!
    To make it easier I took most of the code out, leaving this:

    Sub makro1()
    
    Dim i As Variant
    Dim lastRow As Integer
    Dim actCol As Integer
    Dim actRow As Integer
    Dim lastCol As Integer
    
    'the variables are determined in the code I took out, but will vary from time to time changing according to the data.
    lastCol = 11
    lastRow = 10
    actCol = 5
    actRow = 6
    i = 3
    
    With Cells(lastRow + 3, actCol).Resize(lastRow - actRow, i)
    
    .Formula = Application.WorksheetFunction.SumIf(Range("$E$6:$K$6"), Range("E$12") & "*", Range("$E7:$K7"))
    
    End With
    
    End Sub
    Attached Files Attached Files
    Last edited by timtim89; 02-23-2013 at 11:27 PM.

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