how to handle repetitive errors in excel vba?

Mahesh C A

New Member
Joined
Mar 27, 2018
Messages
6
Dear All,

I written small VB code to check codes are existing in other sheet or not.

If code is not exiting in other sheet it should populate "not eligible" instead of "eligible"

I have 3 sheets in workbook (sheet1: 5000 ID's along with other columns as a PIM and column A as a PIM1 / sheet3: 100 ID's to check these ID's existing in sheet1 or not while using below mentioned VBA code.

In sheet3 some ID's are not existing in sheet1, for those ID's I need to update as a " not eligible" in sheet3. whenever n2 is "#N/A" it should populate "not eligible" in sheet3

Do while Cells(i+1, 1).Value <> ""
n1 = Cells(i+1, 1).Value
n2 = Application.Index(PIM, Application.Match(Cells(i+1, 1), PIM1, 0), 1)
If n1 = n2 Then
Cells(i+1, 7).Value = "Eligible"
Else
Cells(i+1, 7).Value = " Not eligible"
End If
i=i + 1
Loop

if n2 is an error I am getting Run time error '13' Type mismatch, not able to continue for further.

Thank you in advance,

Best Regards,
Mahesh
 
Last edited:

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)
I believe this macro will do what you want...
Code:
[table="width: 500"]
[tr]
	[td]Sub CheckIDs()
  Dim Addr As String
  Addr = "A1:A" & Sheets("Sheet3").Cells(Rows.Count, "A").End(xlUp).Row
  Sheets("Sheet3").Range(Addr).Offset(, 1) = Evaluate("IF(ISNUMBER(MATCH(Sheet3!" & Addr & ",Sheet1!A:A,0)),""eligible"",""not eligible"")")
End Sub[/td]
[/tr]
[/table]
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,248
Members
452,623
Latest member
cliftonhandyman

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