1
votes

I have two cells in my excel workbook that contain vba to perform a formula. What I'm trying to do is put two formulas in one cell instead of two separate ones. I have provided the code below for what I have so far. The outcome I want in cell C1 is to say "AMTS:(count) Cleaners:(count)" both together not separate. I tried just putting the & between the formulas and it kept returning a false value lol. Thanks!

ws.Range("$C$1").Formula = "=""AMTs:("" & COUNTIF(E:E,""AMT"")&"")"""
ws.Range("$D$1").Formula = "=""Cleaners:("" & COUNTIF(E:E,""Cleaner"")&"")"""
1
I am guessing that you've forgotten to remove the equal sign, or that there may be some issues with too many apostrophes. Try ws.Range("$C$1").Formula = "=""AMTs:("" & COUNTIF(E:E,""AMT"")&"") Cleaners:("" & COUNTIF(E:E,""Cleaner"")&"")""" - eirikdaude
works perfect I had way too many apostrophes lol Thank you so much! - Brianna Cates

1 Answers

0
votes
ws.Range("$C$1").Value = "=""AMTs:("" & COUNTIF(E:E,""AMT"")&"")""" & "=""  Cleaners:("" & COUNTIF(E:E,""Cleaner"")&"")"""

enter image description here

This is the output from the macro.

or

ws.Range("$C$1").Formula = "=""AMTs:("" & COUNTIF(E:E,""AMT"")&"")  Cleaners:("" & COUNTIF(E:E,""Cleaner"")&"")"""