Consulting

Results 1 to 7 of 7

Thread: macro

  1. #1
    VBAX Tutor
    Joined
    Dec 2009
    Posts
    295
    Location

    macro

    HI
    Please i neede some help with a macro.

    1) How can i do:that if cell in the range "B2:B100" is activated meaning not empty run marco "home"

    2) how can i do that if one of the values in the range "B2:B100" is greater than 100 write a msgbox with cations signs "out of control"

    thanks

  2. #2
    Quote Originally Posted by oleg_v
    HI
    Please i neede some help with a macro.

    1) How can i do:that if cell in the range "B2:B100" is activated meaning not empty run marco "home"

    2) how can i do that if one of the values in the range "B2:B100" is greater than 100 write a msgbox with cations signs "out of control"

    thanks
    You can use Data Validation to do that

  3. #3
    VBAX Tutor
    Joined
    Dec 2009
    Posts
    295
    Location
    Hi

    I prefer a macro but what is "Data Validation" and how i use it?

  4. #4
    Quote Originally Posted by oleg_v
    Hi

    I prefer a macro but what is "Data Validation" and how i use it?
    Your code in here, pls try

    Private Sub Worksheet_Change(ByVal Target As Range)
    On Error Resume Next
    Dim cell
    If Not Intersect(Range("b2:b100"), Target) Is Nothing And Target.Count = 1 Then
        With Target
            If Target <> "" Then
                Call home ' Run macro Home
                For Each cell In Target
                If cell > 100 Then
                MsgBox "Geater than 100" & vbNewLine & "Pls check again"
                End If
                Next cell
            End If
        End With
      End If
    End Sub

  5. #5
    VBAX Tutor
    Joined
    Dec 2009
    Posts
    295
    Location
    Thank you

    I wanted to ask one more question.
    i need to output msg"fail' in msgbox if 7 consecutive numbers in the column "b" is greater than 78

    thanks

  6. #6
    VBAX Tutor
    Joined
    Dec 2009
    Posts
    295
    Location
    Quote Originally Posted by domfootwear
    Your code in here, pls try

    Private Sub Worksheet_Change(ByVal Target As Range)
    On Error Resume Next
    Dim cell
    If Not Intersect(Range("b2:b100"), Target) Is Nothing And Target.Count = 1 Then
        With Target
            If Target <> "" Then
                Call home ' Run macro Home
                For Each cell In Target
                If cell > 100 Then
                MsgBox "Geater than 100" & vbNewLine & "Pls check again"
                End If
                Next cell
            End If
        End With
      End If
    End Sub


    hi

    it works greate but i have to press an"enter" button to activate
    how it can be done without pressing the "enter"

  7. #7
    Quote Originally Posted by oleg_v
    Thank you

    I wanted to ask one more question.
    i need to output msg"fail' in msgbox if 7 consecutive numbers in the column "b" is greater than 78

    thanks
    Pls check the file in the att.
    http://www.4shared.com/file/21814638...3d/MsgBox.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •