Action depending on cell Value

G

Guest

Hi,

I am trying to get a Macro that create one thing if a Cell Value in a
specific cell is lower than 10000, and something else if the same value is
higher than or equal to 10000.

How do I make this happen?
 
G

Guest

Could you build on this?

Private Sub Worksheet_Change(ByVal Target As Range)
If Cells(1, 1).Value < 10000 Then
MsgBox ("Do Something")
Else
MsgBox ("Do Something else")
End If
End Sub

Mike
 
N

Norman Jones

Hi Tomas,

Try something like:

'=============>>
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rng As Range

Set Rng = Me.Range("A1") '<<==== CHANGE
Set Rng = Intersect(Rng, Target)

If Not Rng Is Nothing Then
With Rng
If .Value < 1000 Then
'do somethimg. e.g.:
MsgBox "Lower"
Else
MsgBox "Higher"
End If
End With
End If
End Sub
'<<=============

This is worksheet event code and should be pasted
into the worksheets's code module (not a standard
module and not the workbook's ThisWorkbook
module):

Right-click the worksheet's tab
Select 'View Code' from the menu and paste the
code.

Alt-F11 to return to Excel.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top