Help with VBA code add concatenated formula to cell

powercell99

New member
Joined
Apr 25, 2014
Messages
2
Reaction score
0
Points
0
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!
 

p45cal

Super Moderator
Staff member
Joined
Dec 16, 2012
Messages
2,199
Reaction score
16
Points
38
Excel Version(s)
365
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?
 

powercell99

New member
Joined
Apr 25, 2014
Messages
2
Reaction score
0
Points
0
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??
 

p45cal

Super Moderator
Staff member
Joined
Dec 16, 2012
Messages
2,199
Reaction score
16
Points
38
Excel Version(s)
365
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"
?
 

p45cal

Super Moderator
Staff member
Joined
Dec 16, 2012
Messages
2,199
Reaction score
16
Points
38
Excel Version(s)
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.
 
Top