Results 1 to 5 of 5

Thread: Help with VBA code add concatenated formula to cell

  1. #1

    Help with VBA code add concatenated formula to cell



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Hi,

    I'm in need of some help with this formula: =PROPER($J2)&", "&PROPER($I2)&" / "&$Z2& " / Total Attendees: "& SUMIFS($AU:$AU,$D:$D, $D2,$C:$C, $C2,$Z:$Z, $Z2) &" / Total Cost: $"& SUMIFS($BB:$BB,$D:$D, $D2,$C:$C, $C2,$Z:$Z, $Z2) &" (vbCr) "&$BZ2

    I cant seem to get vba to accept that concatenated formula into a cell, or find a way to get VBA to put the value result of the formula in Column "AA", specifically Cell "AA2" and every cell below it if cell "A" is not blank. Either method would work for me.

    Any help would be GREATLY appreciated. :-)

    Thanks in advance!

  2. #2
    Super Moderator p45cal's Avatar
    Join Date
    Dec 2012
    Posts
    1,356
    Articles
    0
    Excel Version
    365
    PHP Code:
    ActiveCell.Formula "=PROPER($J2)&"", ""&PROPER($I2)&"" / ""&$Z2& "" / Total Attendees: ""& SUMIFS($AU:$AU,$D:$D$D2,$C:$C$C2,$Z:$Z$Z2) &"" / Total Cost: $""& SUMIFS($BB:$BB,$D:$D$D2,$C:$C$C2,$Z:$Z$Z2) &"" (vbCr) ""&$BZ2
    maybe?

  3. #3
    Thanks for the quick help. Your suggestion gets me really close. It works getting the formula into the cell, but instead of having a carriage return near the very end of the formula and having $BZ2 on the next line of that cell, the formula in the cell shows the (vbCr) instead of the actual carriage return. Any suggestions??

  4. #4
    Super Moderator p45cal's Avatar
    Join Date
    Dec 2012
    Posts
    1,356
    Articles
    0
    Excel Version
    365
    PHP Code:
        ActiveCell.Formula "=PROPER($J2)&"", ""&PROPER($I2)&"" / ""&$Z2& "" / Total Attendees: ""& SUMIFS($AU:$AU,$D:$D$D2,$C:$C$C2,$Z:$Z$Z2) &"" / Total Cost: $""& SUMIFS($BB:$BB,$D:$D$D2,$C:$C$C2,$Z:$Z$Z2) & CHAR(10) & $BZ2
    ?

  5. #5
    Super Moderator p45cal's Avatar
    Join Date
    Dec 2012
    Posts
    1,356
    Articles
    0
    Excel Version
    365
    Could this be what you want?:
    Code:
    Set destnrng = Union(Range(Range("A2"), Range("A" & Rows.Count).End(xlUp)).SpecialCells(xlCellTypeConstants, 23), Range(Range("A2"), Range("A" & Rows.Count).End(xlUp)).SpecialCells(xlCellTypeFormulas, 23)).Offset(, 26)
    destnrng.FormulaR1C1 = "=PROPER(RC10)&"", ""&PROPER(RC9)&"" / ""&RC26& "" / Total Attendees: ""& SUMIFS(C47,C4, RC4,C3, RC3,C26, RC26) &"" / Total Cost: $""& SUMIFS(C54,C4, RC4,C3, RC3,C26, RC26) & CHAR(10) & RC78"
    Don't forget that the destination cells need to have word wrap on to see multiple lines.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •