View Single Post
 
Old 01-07-2015, 03:48 AM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

You are ascribing a single value to a range that comprises multiple locations.
Also you have assigned a variable name to the range and then didn't use it? However this will not affect the result.

If any of the values in the range is a below 50 then the following will indicate 'fail'.

Code:
Private Sub CommandButton21_Click()
Dim marks As Range
Dim bFail As Boolean
Dim n As Integer
    Set marks = Range(Cells(1, 1), Cells(4, 1))
    For n = 1 To marks.Rows.Count
        If marks.Cells(n, 1) < 50 Then
            bFail = True
            Exit For
        End If
    Next n
    If bFail Then
        Range("A6") = "Fail"
    Else
        Range("A6") = "Pass"
    End If
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote