PDA

View Full Version : macro



oleg_v
02-08-2010, 09:53 PM
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

domfootwear
02-08-2010, 10:11 PM
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

oleg_v
02-08-2010, 10:19 PM
Hi

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

domfootwear
02-08-2010, 10:32 PM
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

oleg_v
02-08-2010, 10:54 PM
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

oleg_v
02-08-2010, 11:30 PM
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"

domfootwear
02-08-2010, 11:37 PM
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/218146383/4d77893d/MsgBox.html