Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default custom error messages

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default custom error messages


"RussTheBear" skrev i en meddelelse
...
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default custom error messages

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" skrev i en meddelelse
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error Messages msao Excel Worksheet Functions 4 November 17th 09 04:55 PM
Custom Messages in Excel Mirandah Excel Discussion (Misc queries) 3 September 28th 09 06:12 PM
Error Messages Brian Matlack[_52_] Excel Programming 1 January 23rd 06 11:55 PM
Error Messages Jo Davis Excel Worksheet Functions 1 January 13th 06 12:04 PM
Help with Error Messages Tha BeatMaker[_7_] Excel Programming 1 July 3rd 05 02:51 AM


All times are GMT +1. The time now is 09:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"