ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   macro custom error check (https://www.excelbanter.com/excel-discussion-misc-queries/174912-macro-custom-error-check.html)

RussTheBear

macro custom error check
 
For each matching value I find in column A, I need to check to see whether a
condition is true in another cell in different column but in the same row. I
need to limit the search by the size of the data as opposed to blanks because
there are blanks, so the beginning is necessary.

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

Do Until x = w + 10
Cells(x, 1).Select
A = Cells(x, 1).Value
Cells(x, 3).Select
C = Cells(x, 3).Value
If (A = "purchased") And (C = 0) Then
Cells(x, 3).Select
MsgBox "The selected cell SHOULD have a posting reference number."
Exit Sub
Else
x = x + 1
End If

Loop



All times are GMT +1. The time now is 06:59 PM.

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