PC Review


Reply
Thread Tools Rate Thread

custom error messages

 
 
RussTheBear
Guest
Posts: n/a
 
      30th Jan 2008
I am trying to create a custom error message that evaluates the values of
cells in other columns based on a specific value of one cell in the same row.

This is what I am trying to do:

'First I have to select Column D to measure the amount of rows
'in order to know when to stop

Range("D10").Select
x = ActiveCell.Row
y = ActiveCell.Column
w = 0
Do While Cells(x, y).Value <> ""
x = x + 1
w = w + 1
Loop
Range("A10").Select
x = ActiveCell.Row

'I have to do this until w + 10 because the search starts at 10
'I need to find the value in Column A "#N/A"
'when i find it, I need to make sure there is nothing in the same row of
Column C
'if there is something in Column C, then the error displays
'if there is nothing, then it starts checking the next cell for "#N/A" in
Column A

Do Until x = w + 10

'(the next line of code is where I get the error)

If (Cells(x, 1 = "#N/A") And (Cells(x, 3) <> "") Then
Cells(x, 3).Select
MsgBox "The selected cell SHOULD NOT have a number."
Exit Sub
End If
x = x + 1
Loop

End Sub
 
Reply With Quote
 
 
 
 
Per Jessen
Guest
Posts: n/a
 
      30th Jan 2008

"RussTheBear" <(E-Mail Removed)> skrev i en meddelelse
news:51EAE95D-699A-438D-A20C-(E-Mail Removed)...
>I am trying to create a custom error message that evaluates the values of
> cells in other columns based on a specific value of one cell in the same
> row.
>
> This is what I am trying to do:
>
> 'First I have to select Column D to measure the amount of rows
> 'in order to know when to stop
>
> Range("D10").Select
> x = ActiveCell.Row
> y = ActiveCell.Column
> w = 0
> Do While Cells(x, y).Value <> ""
> x = x + 1
> w = w + 1
> Loop
> Range("A10").Select
> x = ActiveCell.Row
>
> 'I have to do this until w + 10 because the search starts at 10
> 'I need to find the value in Column A "#N/A"
> 'when i find it, I need to make sure there is nothing in the same row of
> Column C
> 'if there is something in Column C, then the error displays
> 'if there is nothing, then it starts checking the next cell for "#N/A" in
> Column A
>
> Do Until x = w + 10
>
> '(the next line of code is where I get the error)
>
> If (Cells(x, 1 = "#N/A") And (Cells(x, 3) <> "") Then
> Cells(x, 3).Select
> MsgBox "The selected cell SHOULD NOT have a number."
> Exit Sub
> End If
> x = x + 1
> Loop
>
> End Sub


Hi

Try something like this.

if cells(x,1).value ="#N/A" and cells(x,3).value <> "" then

Regards,

Per


 
Reply With Quote
 
RussTheBear
Guest
Posts: n/a
 
      31st Jan 2008
This worked, thank you

If IsError(Cells(x, 1).Value) And Cells(x, 3) <> "" Then
Cells(x, 3).Select
MsgBox "The selected cell SHOULD NOT have a number."
Exit Sub
End If
x = x + 1
Loop

"Per Jessen" wrote:

>
> "RussTheBear" <(E-Mail Removed)> skrev i en meddelelse
> news:51EAE95D-699A-438D-A20C-(E-Mail Removed)...
> >I am trying to create a custom error message that evaluates the values of
> > cells in other columns based on a specific value of one cell in the same
> > row.
> >
> > This is what I am trying to do:
> >
> > 'First I have to select Column D to measure the amount of rows
> > 'in order to know when to stop
> >
> > Range("D10").Select
> > x = ActiveCell.Row
> > y = ActiveCell.Column
> > w = 0
> > Do While Cells(x, y).Value <> ""
> > x = x + 1
> > w = w + 1
> > Loop
> > Range("A10").Select
> > x = ActiveCell.Row
> >
> > 'I have to do this until w + 10 because the search starts at 10
> > 'I need to find the value in Column A "#N/A"
> > 'when i find it, I need to make sure there is nothing in the same row of
> > Column C
> > 'if there is something in Column C, then the error displays
> > 'if there is nothing, then it starts checking the next cell for "#N/A" in
> > Column A
> >
> > Do Until x = w + 10
> >
> > '(the next line of code is where I get the error)
> >
> > If (Cells(x, 1 = "#N/A") And (Cells(x, 3) <> "") Then
> > Cells(x, 3).Select
> > MsgBox "The selected cell SHOULD NOT have a number."
> > Exit Sub
> > End If
> > x = x + 1
> > Loop
> >
> > End Sub

>
> Hi
>
> Try something like this.
>
> if cells(x,1).value ="#N/A" and cells(x,3).value <> "" then
>
> Regards,
>
> Per
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom Error Messages =?Utf-8?B?RE1jMjAwNA==?= Microsoft Access Forms 3 14th Jun 2004 07:42 PM
Custom Error Messages =?Utf-8?B?RE1jMjAwNA==?= Microsoft Access Database Table Design 4 11th Jun 2004 11:16 PM
Custom error messages. Eric Microsoft Access Form Coding 3 22nd May 2004 07:23 PM
custom error messages =?Utf-8?B?Um9nZXI=?= Microsoft Access Forms 8 29th Jan 2004 01:41 AM
Custom Error Messages... Nick Wright Microsoft ASP .NET 2 5th Dec 2003 11:20 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:00 AM.