Ed Mah

New Member
Joined
Dec 13, 2003
Messages
26
I have to update some code written by another party. Original code


Code:
    ActiveCell.FormulaR1C1 = "=-SUMPRODUCT(--(LEFT('Data Sheet'!R2C2:R" & LastRowDS & "C2,10)=LEFT('Upload to Database'!RC1,10))," _
                             & "--(LEFT('Data Sheet'!R2C5:R" & LastRowDS & "C5,4)=LEFT('Upload to Database'!RC2,4))," _
                             & "--(LEFT('Data Sheet'!R2C9:R" & LastRowDS & "C9,4)=LEFT('Upload to Database'!RC3,4)), " _
                             & "--(LEFT('Data Sheet'!R2C24:R" & LastRowDS & "C24,4)=""2019"")," _
                             & "'Data Sheet'!R2C20:R" & LastRowDS & "C20)"


Want to add: or (LEFT('Data Sheet'!R2C24:R" & LastRowDS & "C24,5)=""18-19"") and tried but didn't work


Code:
ActiveCell.FormulaR1C1 = "=-SUMPRODUCT(--(LEFT('Data Sheet'!R2C2:R" & LastRowDS & "C2,10)=LEFT('Upload to Database'!RC1,10))," _
                             & "--(LEFT('Data Sheet'!R2C5:R" & LastRowDS & "C5,4)=LEFT('Upload to Database'!RC2,4))," _
                             & "--(LEFT('Data Sheet'!R2C9:R" & LastRowDS & "C9,4)=LEFT('Upload to Database'!RC3,4)), " _
                             & "--(LEFT('Data Sheet'!R2C24:R" & LastRowDS & "C24,4)=""2019"") or (LEFT('Data Sheet'!R2C24:R" & LastRowDS & "C24,5)=""18-19"")," _
                             & "'Data Sheet'!R2C20:R" & LastRowDS & "C20)"


How do I correct it?
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Hi,

Your missing criteria, like an IF function, to distinguish what text to add to the end result of the formula.
If there's no criteria and it's needs to be added to the formula change your OR part to &
 
Last edited:
Upvote 0
If I understand correctly the SUMPRODUCT acts similar to an IF statement. Each additional criteria, creates an smaller subset.

What I'm after is "any data = 2019 OR data = 18/19". I don't want "data = 2019 AND data =18/19"
 
Upvote 0

Forum statistics

Threads
1,214,982
Messages
6,122,573
Members
449,089
Latest member
Motoracer88

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