Type Mismatch error

gtd526

Well-known Member
Joined
Jul 30, 2013
Messages
675
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

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
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,223,101
Messages
6,170,116
Members
452,302
Latest member
TaMere

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