vba to evaluate every cell from BI49 to the last row and if there's an N/A then pop up an error message and exit program

parkerbelt

Active Member
Joined
May 23, 2014
Messages
377
I'm looking for the vba to evaluate every cell from BI49 to the last row and if there's an N/A then pop up an error message and exit program.

I had a similar request yesterday, but I can't get the syntax right.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
if you quit automatically post message then surely you can't fix in programme
 
Upvote 0
If the range contains N/A rather than #N/A try
Code:
Sub Chk()
If WorksheetFunction.CountIf(Range("BI49", Range("BI" & Rows.Count).End(xlUp)), "N/A") Then
   MsgBox "N/A occurs"
   Exit Sub
End If
End Sub
 
Upvote 0
That worked! It was #N/A, so I changed the code. Thank you!!

If the range contains N/A rather than #N/A try
Code:
Sub Chk()
If WorksheetFunction.CountIf(Range("BI49", Range("BI" & Rows.Count).End(xlUp)), "N/A") Then
   MsgBox "N/A occurs"
   Exit Sub
End If
End Sub
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,216,030
Messages
6,128,418
Members
449,449
Latest member
Quiet_Nectarine_

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