Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Error Messages | Excel Worksheet Functions | |||
Custom Messages in Excel | Excel Discussion (Misc queries) | |||
Error Messages | Excel Programming | |||
Error Messages | Excel Worksheet Functions | |||
Help with Error Messages | Excel Programming |