+ Reply to Thread
Results 1 to 4 of 4

Putting formulas into vba

Hybrid View

  1. #1
    Registered User
    Join Date
    06-18-2019
    Location
    Dallas, Texas
    MS-Off Ver
    windows 2013
    Posts
    72

    Putting formulas into vba

    Hello, I have the current (below formulas) and I need to put them in VBA filling them down to the last cell.
    (M3) =IFERROR(AGGREGATE(15,6,Data!I$2:I$101/(Data!E$2:E$101>=A3)/(Data!G$2:G$101<=A4)/ISNUMBER(MATCH(Data!$K$2:$K$101,Notes!$S$2:$S$9,)),1),"-")
    (N3) =IFERROR(AGGREGATE(14,6,Data!I$2:I$101/(Data!E$2:E$101>=A3)/(Data!G$2:G$101<=A4)/ISNUMBER(MATCH(Data!$K$2:$K$101,Notes!$S$2:$S$9,)),1), "-")
    (O3) = IFERROR(SUMPRODUCT(Data!I$2:I$101,(Data!E$2:E$101>A3)*(Data!G$2:G$101<=A4)*ISNUMBER(MATCH(Data!$K$2:$K$101,Notes!$S$2:$S$9,)))/F3, "-")
    (P3) = IFERROR(SUMPRODUCT(Data!J$2:J$101,(Data!E$2:E$101>A3)*(Data!G$2:G$101<=A4)*ISNUMBER(MATCH(Data!$K$2:$K$101,Notes!$S$2:$S$9,)))/F3, "-")
    (Q3) = IFERROR(SUMPRODUCT((Data!E$2:E$101>A3)*(Data!G$2:G$101<=A4)*ISNUMBER(MATCH(Data!$K$2:$K$101,Notes!$S$2:$S$9,))),"-")
    (R3) =  IFERROR(N3-M3,"-")

    How would I put the ABOVE formulas into code


    then for fill down,
    I was thinking of using
        Range("M3", "M" & Cells(Rows.Count, 1).End(xlUp).Row).FillDown
    or
    should i use:
     lastRow = ActiveSheet.UsedRange.Rows.Count
    Range("M3").Select
    Selection.AutoFill Destination:=Range("M3:M" & lastRow)
    Last edited by Tgbell; 07-09-2019 at 09:34 AM.

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,888

    Re: Putting formulas into vba

    If the formulae are already in row 3, I would use
     Range("M3:R" & Cells(Rows.Count, 1).End(xlUp).Row).FillDown

  3. #3
    Registered User
    Join Date
    06-18-2019
    Location
    Dallas, Texas
    MS-Off Ver
    windows 2013
    Posts
    72

    Re: Putting formulas into vba

    what about for inserting in the formulas?

  4. #4
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,888

    Re: Putting formulas into vba

    Like
    Range("M3").Formula = "=IFERROR(AGGREGATE(15,6,Data!I$2:I$101/(Data!E$2:E$101>=A3)/(Data!G$2:G$101<=A4)/ISNUMBER(MATCH(Data!$K$2:$K$101,Notes!$S$2:$S$9,)),1),""-"")"
    Range("N3").Formula = "=IFERROR(AGGREGATE(14,6,Data!I$2:I$101/(Data!E$2:E$101>=A3)/(Data!G$2:G$101<=A4)/ISNUMBER(MATCH(Data!$K$2:$K$101,Notes!$S$2:$S$9,)),1), "" - "")"
    Just remember to double-up the quotes inside the formula

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. putting rows together...
    By johny46 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-08-2017, 06:26 AM
  2. [SOLVED] Putting cell formulas into a VBA form
    By LightHeart7 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-19-2013, 07:06 PM
  3. HELP with putting some formulas in a pivot table!
    By ef456 in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 10-13-2013, 05:35 AM
  4. Putting on a cap
    By jdplunkett89 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-06-2009, 12:16 PM
  5. Putting data/using formulas on an image
    By AKL in forum Excel General
    Replies: 1
    Last Post: 07-08-2009, 10:05 AM
  6. [SOLVED] Putting Excel formatting and/or formulas into CSV file
    By Frank D. Nicodem, Jr. in forum Excel General
    Replies: 1
    Last Post: 07-11-2005, 06:05 PM
  7. Replies: 4
    Last Post: 02-18-2005, 08:06 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