ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   determine if cell is #N/A (https://www.excelbanter.com/excel-programming/391602-determine-if-cell-n.html)

Clayman

determine if cell is #N/A
 
I would like to find out if only a certain cell is #N/A due to faulty data
coming in. Will OnError allow me to prompt the user to input data for the
faulty cell? Or, can I just check for an error in the cell and call a
userform iwth the input?

Code:
For ediro = 4 To 199
With edi
If .Cells(ediro, 40).Type = xlerror Then
' Form_VacRate will accept input from the user to enter into .Cells(ediro,40)
With Form_VacRate
.TBempname = empname
.TBempname.Locked = True
.TBfilenum = empnum
.TBfilenum.Locked = True
.Show
End If
vacation = .Cells(ediro, 40).Value
End With
next ediro
--
Adios,
Clay Harryman

Chip Pearson

determine if cell is #N/A
 
Clay,

You can adapt the following code to suit your needs.

Dim R As Range
Dim V As Variant
Set R = Range("A1")
If IsError(R) = True Then
If R.Value = CVErr(xlErrNA) Then
Debug.Print "N/A ERROR"
Else
Debug.Print "OTHER ERROR"
End If
Else
Debug.Print "NO ERROR"
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)



"Clayman" wrote in message
...
I would like to find out if only a certain cell is #N/A due to faulty data
coming in. Will OnError allow me to prompt the user to input data for the
faulty cell? Or, can I just check for an error in the cell and call a
userform iwth the input?

Code:
For ediro = 4 To 199
With edi
If .Cells(ediro, 40).Type = xlerror Then
' Form_VacRate will accept input from the user to enter into
.Cells(ediro,40)
With Form_VacRate
.TBempname = empname
.TBempname.Locked = True
.TBfilenum = empnum
.TBfilenum.Locked = True
.Show
End If
vacation = .Cells(ediro, 40).Value
End With
next ediro
--
Adios,
Clay Harryman



Clayman

determine if cell is #N/A
 
Thank you.

I guess what I was looking for was the CVErr(xlErrNA).

I'll get rollin' on it!
--
Adios,
Clay Harryman


"Chip Pearson" wrote:

Clay,

You can adapt the following code to suit your needs.

Dim R As Range
Dim V As Variant
Set R = Range("A1")
If IsError(R) = True Then
If R.Value = CVErr(xlErrNA) Then
Debug.Print "N/A ERROR"
Else
Debug.Print "OTHER ERROR"
End If
Else
Debug.Print "NO ERROR"
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)



"Clayman" wrote in message
...
I would like to find out if only a certain cell is #N/A due to faulty data
coming in. Will OnError allow me to prompt the user to input data for the
faulty cell? Or, can I just check for an error in the cell and call a
userform iwth the input?

Code:
For ediro = 4 To 199
With edi
If .Cells(ediro, 40).Type = xlerror Then
' Form_VacRate will accept input from the user to enter into
.Cells(ediro,40)
With Form_VacRate
.TBempname = empname
.TBempname.Locked = True
.TBfilenum = empnum
.TBfilenum.Locked = True
.Show
End If
vacation = .Cells(ediro, 40).Value
End With
next ediro
--
Adios,
Clay Harryman




All times are GMT +1. The time now is 01:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com