LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 135
Default code to check condition for each row

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

 
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
Check & Convert cell Value if condition auto SteveT Excel Discussion (Misc queries) 3 June 25th 08 11:10 PM
Code to delete columns meeting a condition CEG Excel Discussion (Misc queries) 6 February 5th 07 05:03 PM
Continually check if condition is true in VBA [email protected] Excel Discussion (Misc queries) 1 October 4th 06 05:43 PM
comparing two dates and executing code on condition ashish128 Excel Discussion (Misc queries) 4 August 31st 06 10:45 AM


All times are GMT +1. The time now is 11:04 AM.

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

About Us

"It's about Microsoft Excel"