Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Excel macro needed

  • 11-07-2007 10:45AM
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 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, Registered Users 2 Posts: 396 ✭✭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