Run a Macro when value is...
Closed
cprevoisin
Posts
3
Registration date
Thursday September 5, 2013
Status
Member
Last seen
September 6, 2013
-
Sep 5, 2013 at 03:11 PM
Blocked Profile - Sep 6, 2013 at 07:30 PM
Blocked Profile - Sep 6, 2013 at 07:30 PM
Hello! I have been trying to run a Macro within a worksheet. Running the macro depends on the value of a cell, it can be 6 or 4 (Changes depending on a calculation). If its 4, I need to run MacroA, and if its 6, I need to Run MacroB.
I know that I need to go to the Visual Basic but can't figure out the lines! Can someone help me please!!!!
I know that I need to go to the Visual Basic but can't figure out the lines! Can someone help me please!!!!
Related:
- Run a Macro when value is...
- Spell number in excel without macro - Guide
- Excel macro to create new sheet based on value in cells - Guide
- Excel run macro when opening workbook - Guide
- Run macro when cell value changes by formula - Guide
- Macro excel download - Download - Spreadsheets
3 responses
Good Afternoon,
Insert this when the workbook sheet is changed:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim valueX
valueX = Sheet1.Range("A4")
If valueX = "4" Then
MsgBox ("your macro a here")
Else
MsgBox ("your macro b here")
End If
End Sub
Have Fun!
Insert this when the workbook sheet is changed:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim valueX
valueX = Sheet1.Range("A4")
If valueX = "4" Then
MsgBox ("your macro a here")
Else
MsgBox ("your macro b here")
End If
End Sub
Have Fun!
cprevoisin
Posts
3
Registration date
Thursday September 5, 2013
Status
Member
Last seen
September 6, 2013
Sep 5, 2013 at 08:05 PM
Sep 5, 2013 at 08:05 PM
Thank you very much! But I still have a problem. The macro wont run...?! Do I need to make something else so it knows the value in the cell changed?
Also, is it possible to do this?
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim valueX
valueX = Sheet1.Range(AQ4)
If valueX = "4" Then
MsgBox (AlturaA)
Else
Dim valueX
valueX = Sheet1.Range(AQ4)
If valueX = "6" Then
MsgBox (AlturaB)
End If
This is because I need the Macros to work with the two different values...
Thank you very much for your help!
Also, is it possible to do this?
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim valueX
valueX = Sheet1.Range(AQ4)
If valueX = "4" Then
MsgBox (AlturaA)
Else
Dim valueX
valueX = Sheet1.Range(AQ4)
If valueX = "6" Then
MsgBox (AlturaB)
End If
This is because I need the Macros to work with the two different values...
Thank you very much for your help!
cprevoisin
Posts
3
Registration date
Thursday September 5, 2013
Status
Member
Last seen
September 6, 2013
Sep 6, 2013 at 04:43 PM
Sep 6, 2013 at 04:43 PM
How do i save it that way? It doesn't gives me an option.:(