Results 1 to 12 of 12

assistance to make a vba code run on a dynamic range

Threaded View

  1. #1
    Forum Contributor
    Join Date
    02-11-2014
    Location
    mauritius
    MS-Off Ver
    MS365
    Posts
    1,086

    assistance to make a vba code run on a dynamic range

    Hi All

    I have a work tab and a summary tab , the summary tab represent the consolidation of columns in green using sumifs

    I recorded a macro how the figures are consolidated from column range S TO U then column AC ON SUMMARY sheet tab as per their respective headers .


    The range is dynamic as it can lead to 10000 rows or more .

    Looking assistance to adjust recorded macro to last data row making it dynamic .

    The active sheet should be the summary tab sheet when code is triggered

    
    Sub TESTSUMIFS11()
    '
    ' TESTSUMIFS11 Macro
    '
    
    '
        ActiveCell.FormulaR1C1 = _
            "=SUMIFS(WORK!R2C19:R58C19,WORK!R2C8:R58C8,SUMMARY!RC1,WORK!R2C9:R58C9,SUMMARY!RC2,WORK!R2C11:R58C11,SUMMARY!RC3)"
        Range("D2").Select
        Selection.AutoFill Destination:=Range("D2:D20"), Type:=xlFillDefault
        Range("D2:D20").Select
        Range("E2").Select
        ActiveCell.FormulaR1C1 = _
            "=SUMIFS(WORK!R2C20:R58C20,WORK!R2C8:R58C8,SUMMARY!RC1,WORK!R2C9:R58C9,SUMMARY!RC2,WORK!R2C11:R58C11,SUMMARY!RC3)"
        Range("E2").Select
        Selection.AutoFill Destination:=Range("E2:E20"), Type:=xlFillDefault
        Range("E2:E20").Select
        Range("F2").Select
        ActiveCell.FormulaR1C1 = _
            "=SUMIFS(WORK!R2C21:R58C21,WORK!R2C8:R58C8,SUMMARY!RC1,WORK!R2C9:R58C9,SUMMARY!RC2,WORK!R2C11:R58C11,SUMMARY!RC3)"
        Range("F2").Select
        Selection.AutoFill Destination:=Range("F2:F20"), Type:=xlFillDefault
        Range("F2:F20").Select
        Range("G2").Select
        ActiveCell.FormulaR1C1 = _
            "=SUMIFS(WORK!R2C22:R58C22,WORK!R2C8:R58C8,SUMMARY!RC1,WORK!R2C9:R58C9,SUMMARY!RC2,WORK!R2C11:R58C11,SUMMARY!RC3)"
        Range("G2").Select
        Selection.AutoFill Destination:=Range("G2:G20")
        Range("G2:G20").Select
        Range("H2").Select
        ActiveCell.FormulaR1C1 = _
            "=SUMIFS(WORK!R2C29:R58C29,WORK!R2C8:R58C8,SUMMARY!RC1,WORK!R2C9:R58C9,SUMMARY!RC2,WORK!R2C11:R58C11,SUMMARY!RC3)"
        Range("H2").Select
        Selection.AutoFill Destination:=Range("H2:H20"), Type:=xlFillDefault
        Range("H2:H20").Select
        Range("D21:H21").Select
        Selection.FormulaR1C1 = "=SUM(R[-19]C:R[-1]C)"
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Make a range dynamic for edition!
    By Hellion in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-25-2016, 02:13 PM
  2. [SOLVED] How to amend VBA code to make it more dynamic?
    By The_Snook in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-11-2016, 06:30 PM
  3. [SOLVED] How to make the following code dynamic?
    By Rerock in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-19-2015, 03:55 PM
  4. [SOLVED] HOw to make a chart range dynamic
    By ammartino44 in forum Excel General
    Replies: 7
    Last Post: 09-21-2015, 02:06 PM
  5. Simply VBA code and make it dynamic
    By Rusty315 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-09-2014, 02:49 AM
  6. How should I make a SUMIF w/ dynamic range?
    By jwright650 in forum Excel General
    Replies: 8
    Last Post: 03-21-2014, 06:29 AM
  7. [SOLVED] Make Static code Dynamic
    By Rick_Stanich in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-05-2012, 11:09 AM

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