Replace formula in this code

RAJESH1960

Banned for repeated rules violations
Joined
Mar 26, 2020
Messages
2,313
Office Version
  1. 2019
Platform
  1. Windows
Hello guys, I need your help to replace the formula in the code with the new formula.

Rich (BB code):
With wsDestination.Range(DestinationRemarksColumn & "2")
        .FormulaArray = "=IFERROR(IF(ROW(B2)<=SMALL(IF((ABS(" & DSCol & "2-$" & DSCol & "$2:$" & DSCol & _
                "$20000)<=1)*(C2=$C$2:$C$20000)*(B2=$B$2:$B$20000),ROW($A$2:$A$20000),""""),xxxxxx)" & _
                ",""Matched"",NA()),NA())"                                                              '   Formula to insert into 'Remarks' column
        .Replace "xxxxxx", FormulaReplacementString1, xlPart                                            '   Insert additional string into formula
    End With
New formula
Rich (BB code):
=IF(MATCH(1,((ABS(G2-$G$2:$G$23200)<=1))*(C2=$C$2:$C$23200)*(F2=$F$2:$F$23200)*(B2<>$B$2:$B$23200),0),"Matched","")
Old formula
Rich (BB code):
=IF(MATCH(1,((ABS(G2-$G$2:$G$23200)<=1))*(C2=$C$2:$C$23200)*(B2<>$B$2:$B$23200),0),"Matched","")
 
In the sheet I tested, I am getting 26 matches out of 40 using the new formula with control + shift + enter.
mikerickson's formula.xlsx
ABCDEFGHIJ
21PORTAL07XXXTB0431R1XD0000CR201900089322-05-2019900.00Matched
3108TALLY07XXXTB0431R1XD22-05-2019901.00Matched
42PORTAL07XXXTB0431R1XD0000CR201900116205-06-2019900.00Matched
53PORTAL07XXXTB0431R1XD0000CR201900116305-06-2019900.00Matched
64PORTAL07XXXTB0431R1XD0000CR201900116405-06-2019900.00Matched
7109TALLY07XXXTB0431R1XD05-06-2019899.00Matched
8110TALLY07XXXTB0431R1XD0000CR201900116305-06-2019900.00Matched
9111TALLY07XXXTB0431R1XD05-06-2019901.00Matched
105PORTAL07XXXTB0431R1XD0000CR201900180912-07-2019900.00Matched
11112TALLY07XXXTB0431R1XD12-07-2019900.00Matched
126PORTAL07XXXTB0431R1XD0000CR201900213126-07-2019900.00Matched
13113TALLY07XXXTB0431R1XD26-07-2019901.00Matched
147PORTAL07XXXTB0431R1XD0000CR201900227603-08-2019900.00Matched
15114TALLY07XXXTB0431R1XD03-08-2019899.50Matched
168PORTAL07XXXTB0431R1XD0000CR201900307619-09-2019900.00Matched
17115TALLY07XXXTB0431R1XD19-09-2019900.50Matched
189PORTAL07XXXTB0431R1XD0000CR201900312623-09-2019900.00Matched
19116TALLY07XXXTB0431R1XD312623-09-2019900.00Matched
2010PORTAL07XXXTB0431R1XD0000CR201900594628-02-2020900.00Matched
21117TALLY07XXXTB0431R1XD28-02-2020900.00Matched
2211PORTAL19XXECS5031Q1XVGST-065/19-2006-02-20201881.00Matched
23118TALLY19XXECS5031Q1XV6506-02-20201881.50Matched
2412PORTAL19XXECS5031Q1XVGST-052/19-2025-12-20192520.00#N/A
2513PORTAL19XXECS5031Q1XVGST-053/19-2004-01-20202520.00Matched
26119TALLY19XXECS5031Q1XV5304-01-20202520.00Matched
2714PORTAL19XXECS5031Q1XVGST-057/19-2013-01-20202520.00Matched
28120TALLY19XXECS5031Q1XV5713-01-20202519.50Matched
29121TALLY27XXOFD3597R1XC44601-01-20207520.90#N/A
30122TALLY27XXOFD3597R1XC44701-01-20207521.00#N/A
31123TALLY27XXOFD3597R1XC44801-01-20207522.00#N/A
32124TALLY27XXOFD3597R1XC44401-01-20207521.45#N/A
33125TALLY27XXOFD3597R1XC44501-01-20207521.45#N/A
34126TALLY27XXOFD3597R1XC44301-01-20207521.50#N/A
3515PORTAL27XXOFD3597R1XCDEI-00438/19-2029-12-20197521.58#N/A
3616PORTAL27XXOFD3597R1XCDEI-00443/19-2030-12-20197521.58#N/A
3717PORTAL27XXOFD3597R1XC44430-12-20197521.58#N/A
3818PORTAL27XXOFD3597R1XCDEI-00445/19-2030-12-20197521.58#N/A
3919PORTAL27XXOFD3597R1XCDEI-00446/19-2031-12-20197521.58#N/A
4020PORTAL27XXOFD3597R1XCDEI-00447/19-2031-12-20197521.58#N/A
4121PORTAL27XXOFD3597R1XC44831-12-20197521.58#N/A
Matched
Cell Formulas
RangeFormula
J2:J41J2=IF(MATCH(1,((ABS(G2-$G$2:$G$23200)<=1))*(C2=$C$2:$C$23200)*(F2=$F$2:$F$23200)*(B2<>$B$2:$B$23200),0),"Matched","")
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
So again I will ask you, Do you want to use the Excel acceptable version of a formula from post #1, or are you wanting to try and fail using the non acceptable formula that you proposed that has the 'NA' stuff at the end?
 
Upvote 0
I am not getting it. It is the same formula I used in the sheet that is in post #1. Only thing when you try to copy the formula and paste it in the thread, maybe it looks different i.e., {} are missing
 
Upvote 0
You posted a formula in post #19 here. I asked if that was what you wanted to use. You responded with 'Yes'. That formula is not the same as the 'New' formula in post #1.
 
Upvote 0
So show me what vba code you will try to use that reflects the code from post #1 instead of the formula you tried to use in post #19.
 
Upvote 0
Rich (BB code):
    With wsDestination.Range(DestinationRemarksColumn & "2")
        .FormulaArray = "=IFERROR(IF(ROW(B2)<=SMALL(IF((ABS(" & DSCol & "2-$" & DSCol & "$2:$" & DSCol & _
                $23200)<=1))*(C2=$C$2:$C$23200)*(F2=$F$2:$F$23200)*(B2<>$B$2:$B$23200),ROW($A$2:$A$23200),""""),xxxxxx)" & _
                ",""Matched"",NA()),NA())"                                                              '   Formula to insert into 'Remarks' column
    End With
In the above code, when I added only *(F2=$F$2:$F$23200) in your code it was running but showing all mismatches and when I replaced the whole formula with this I got a syntax error.
With wsDestination.Range(DestinationRemarksColumn & "2")
.FormulaArray = "=IF(MATCH(1,((ABS(G2-$G$2:$G$23200)<=1))*(C2=$C$2:$C$23200)*(F2=$F$2:$F$23200)*(B2<>$B$2:$B$23200),0),"Matched","",NA()),NA())" ' Formula to insert into 'Remarks' column
End With
 
Upvote 0
Were going backwards again.

Read Post #20. I said we were getting somewhere. That was referring to your post #19. I have said the formula in post #19 is not right. I also said that the 'New' formula from post #1 is acceptable by excel. That was a clue to you to replace the formula code from post #19 that was very close, with the 'New' formula from Post #1.

So fix what you had in post #19 with the code from the 'New' formula from post #1 and post here what the code will look like, that is very similar to post #19, but without that 'NA' stuff at the end.

Do that correctly, and you are one step away from the proper vba code to try.
 
Upvote 0
Rich (BB code):
With wsDestination.Range(DestinationRemarksColumn & "2")
        .FormulaArray = "=IF(MATCH(1,((ABS(G2-$G$2:$G$23200)<=1))*(C2=$C$2:$C$23200)*(F2=$F$2:$F$23200)*(B2<>$B$2:$B$23200),0),"Matched",""                                                            '   Formula to insert into 'Remarks' column
    End With
 
Upvote 0

Forum statistics

Threads
1,215,200
Messages
6,123,598
Members
449,109
Latest member
Sebas8956

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