Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Excel macro needed

Options
  • 11-07-2007 10:45am
    #1
    Registered Users Posts: 102 ✭✭


    I have a problem with Excel macros. I want to write a simple macro that will check a column of numbers and tell me if any value is less then a certain set value. For example if the set value is 10 and the column of numbers is: 11, 13, 15, 16, 25, 8, 14. The macro when run should display a message telling me that one of the values is less than the set value. I have no macro experience so I was hoping one of you guys could help me out.

    Seamus


Comments

  • Registered Users Posts: 901 ✭✭✭EL_Loco


    can you do it on the sheet itself?
    eg:
    all your values in A
    in C1 put the value you want to check against in your example 10.
    in B1 and as far down as you want to you use this equation (type it into B1 then copy and paste all the way down)

    =IF(A1>=$C$1,"Yes","No")


  • Registered Users Posts: 363 ✭✭Edser


    For a visual check you could use Conditional formatting..

    Select cells, go to menu: Format\Conditional formatting - enter 'Cell Value is' 'less than' 10, and format cells to red (Click Format button & Pattern = Red).


    Or this macro should work..

    Sub Cells1()
    Dim cell As Range
    For Each cell In Selection.Cells
    If cell.Value < 10 Then
    MsgBox ("A value in the selection is less than 10")
    Exit Sub
    End If
    Next
    MsgBox ("There are no values less than 10 in the selection")
    End Sub

    Notes: 1, Highlight your cells before running. 2, this macro will only tell you if there is a value less than 10, not the value or cell ref.

    Rgds,
    Ed


  • Closed Accounts Posts: 82 ✭✭cyberbob


    EL_Loco wrote:
    can you do it on the sheet itself?
    eg:
    all your values in A
    in C1 put the value you want to check against in your example 10.
    in B1 and as far down as you want to you use this equation (type it into B1 then copy and paste all the way down)

    =IF(A1>=$C$1,"Yes","No")


    or countif()...


Advertisement