Type Mismatch error

gtd526

Well-known Member
Joined
Jul 30, 2013
Messages
696
Office Version
  1. 2019
Platform
  1. Windows
Hello,
Im receiving a Type Mismatch error on the enter formula line.
How can this be resolved?
The formula works fine when entered manually.

VBA Code:
    Dim c As Range
 
    For Each c In Range("U27:AF27")
        If c.Value < Date Then
            c.Offset(1, 0).Value = _
            "=IF(SUMIFS($E$3:$E$30,$B$3:$B$30," >= "&U$27,$B$3:$B$30," < "&EDATE(U$27,1))+SUMIFS($K$3:$K$30,$H$3:$H$30," >= "&U$27,$H$3:$H$30," < "&EDATE(U$27,1))+SUMIFS($P$3:$P$30,$N$3:$N$30," >= "&U$27,$N$3:$N$30," < "&EDATE(U$27,1))=0,"",SUMIFS($E$3:$E$30,$B$3:$B$30," >= "&U$27,$B$3:$B$30," < "&EDATE(U$27,1))+SUMIFS($K$3:$K$30,$H$3:$H$30," >= "&U$27,$H$3:$H$30," < "&EDATE(U$27,1))+SUMIFS($P$3:$P$30,$N$3:$N$30," >= "&U$27,$N$3:$N$30," < "&EDATE(U$27,1)))"
        End If
    Next

Thank you
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
You have to escape the inner double quotes with an additional double quote. Leave the outer double quotes there.

VBA Code:
"=IF(SUMIFS($E$3:$E$30,$B$3:$B$30,"" >= ""&U$27,$B$3:$B$30,"" < ""&EDATE(U$27,1))+SUMIFS($K$3:$K$30,$H$3:$H$30,"" >= ""&U$27,$H$3:$H$30,"" < ""&EDATE(U$27,1))+SUMIFS($P$3:$P$30,$N$3:$N$30,"" >= ""&U$27,$N$3:$N$30,"" < ""&EDATE(U$27,1))=0,"""",SUMIFS($E$3:$E$30,$B$3:$B$30,"" >= ""&U$27,$B$3:$B$30,"" < ""&EDATE(U$27,1))+SUMIFS($K$3:$K$30,$H$3:$H$30,"" >= ""&U$27,$H$3:$H$30,"" < ""&EDATE(U$27,1))+SUMIFS($P$3:$P$30,$N$3:$N$30,"" >= ""&U$27,$N$3:$N$30,"" < ""&EDATE(U$27,1)))"
 
Upvote 0
You have to escape the inner double quotes with an additional double quote. Leave the outer double quotes there.

VBA Code:
"=IF(SUMIFS($E$3:$E$30,$B$3:$B$30,"" >= ""&U$27,$B$3:$B$30,"" < ""&EDATE(U$27,1))+SUMIFS($K$3:$K$30,$H$3:$H$30,"" >= ""&U$27,$H$3:$H$30,"" < ""&EDATE(U$27,1))+SUMIFS($P$3:$P$30,$N$3:$N$30,"" >= ""&U$27,$N$3:$N$30,"" < ""&EDATE(U$27,1))=0,"""",SUMIFS($E$3:$E$30,$B$3:$B$30,"" >= ""&U$27,$B$3:$B$30,"" < ""&EDATE(U$27,1))+SUMIFS($K$3:$K$30,$H$3:$H$30,"" >= ""&U$27,$H$3:$H$30,"" < ""&EDATE(U$27,1))+SUMIFS($P$3:$P$30,$N$3:$N$30,"" >= ""&U$27,$N$3:$N$30,"" < ""&EDATE(U$27,1)))"
Thank you. I put the double-quotes only to the outside quotes (first and last), not the inner quotes.
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top