ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Action depending on cell Value (https://www.excelbanter.com/excel-programming/389104-action-depending-cell-value.html)

Tomas Stroem

Action depending on cell Value
 
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?
--
Tomas S

Mike H

Action depending on cell Value
 
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

"Tomas Stroem" wrote:

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?
--
Tomas S


Norman Jones

Action depending on cell Value
 
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.


---
Regards,
Norman


"Tomas Stroem" wrote in message
...
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?
--
Tomas S





All times are GMT +1. The time now is 09:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com