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","")
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
For closure, the following code would be the 'New' formula with what you were trying to combine with the previous formula variable used.

VBA Code:
    With wsDestination.Range(DestinationRemarksColumn & "2")
        .FormulaArray = "=IF(MATCH(1,((ABS(" & DSCol & "2-$" & DSCol & "$2:$" & DSCol & _
                "$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
Rich (BB code):
    'FormulaReplacementString1 = "MIN(SUM(IF(($C$2:$C$20000=C2)*(ABS(" & DSCol & "2-$" & DSCol & "$2:$" & _
      '      DSCol & "$20000)<=1)*($B$2:$B$20000=""PORTAL""),1,0)),SUM(IF(($C$2:$C$20000=C2)*(ABS(" & _
     '       DSCol & "2-$" & DSCol & "$2:$" & DSCol & "$20000)<=1)*($B$2:$B$20000=""TALLY""),1,0)))"     ' Additional string to insert into formula
'
    '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
    
    With wsDestination.Range(DestinationRemarksColumn & "2")
         .FormulaArray = "=IF(MATCH(1,((ABS(" & DSCol & "2-$" & DSCol & "$2:$" & DSCol & _
                "$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
        .Replace "xxxxxx", FormulaReplacementString1, xlPart                                            '   Insert additional string into formula
    
    End With
    
    '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
'
I tested with both the edited codes. I am facing another problem now. I have commented the old codes for reference. I first tested it the lines not commented in the above code, with the line .Replace "xxxxxx", FormulaReplacementString1, xlPart ' Insert additional string into formula
and tested again after deleting this line. In both the cases I am getting 2 unwanted rows in Edited portal sheet which are copied to the mismatched sheet too.
 
Upvote 0
Last 2 rows error.png
 
Upvote 0
These last 2 lines were not appearing with the old formula. So, the error has to be due to the lines with the formula which were edited.
 
Upvote 0
Deleted the whole code and tested again replacing only your final formula. It is good now. ?
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,241
Members
452,622
Latest member
Laura_PinksBTHFT

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