Return Value that from range that is not matching to the assigned Array Value.

hennLow

New Member
Joined
Jul 29, 2021
Messages
8
Office Version
  1. 2019
Platform
  1. Windows
Hi I have this lines of code which is finding the value from the array and replacing it by the user, however what I wanted to do is, when the code runs, it will return the value that are not included from the array and replace it by the user.
VBA Code:
Sub upload_data_practice()

Dim FndWrd As Variant, RpWrd As Variant

 fndList = Array("Apple","Mango","banana","pineapple")
        'Loop through each item in Array lists
  For x = LBound(fndList) To UBound(fndList)
    'Loop through each worksheet in ActiveWorkbook
  Set FndWrd = WSdest.Cells.Find(fndList(x), , , , xlByRows, , False, , False)
  Set Stat = Range("q2:q20000")
  If Not FndWrd = Stat.Value Then
  RpWrd = InputBox("Replace " & fndList(x) & "  " & "with:")
  End If
  
        WSdest.Cells.Replace What:=fndList(x), Replacement:=RpWrd, _
          LookAt:=xlWhole, SearchOrder:=xlByRows, MatchCase:=False, _
          SearchFormat:=False, ReplaceFormat:=False
Next x
ActiveWorkbook.Close False
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub

This is what I have right now and It is not returning the value that are not present from the array please help.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Forum statistics

Threads
1,224,823
Messages
6,181,170
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