Thread
:
code to check condition for each row
View Single Post
#
2
Posted to microsoft.public.excel.misc
Don Guillett
external usenet poster
Posts: 10,124
code to check condition for each row
try this idea
for i=3 to 42
if cells(i,"p")4 then msgbox "error on "&cells(i,"a")
next i
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
"Horatio J. Bilge, Jr." wrote in
message ...
I am trying to write a macro that will check the last cell in each row of a
range against a condition. If the condition is met, then the value of the
first cell in the row is added to a string. The string will be used for a
message box.
The range("A3:P42") has names in the first column, data in the middle
columns, and totals in the last column. I'm trying to use a for-next loop,
but I'm stuck on how to refer to the correct cell. This is what I have
tried:
Private Sub cmdErrorCheck_Click()
Dim e As String
For Each .Row In Me.Range("A3:P42")
If [the last cell].Value 4 Then
e = e & [the first cell].Value
End If
Next .Row
MsgBox "There is an error on these people: " & e
End Sub
Reply With Quote
Don Guillett
View Public Profile
Find all posts by Don Guillett