macro

  • Thread starter Thread starter naeemsbp
  • Start date Start date
N

naeemsbp

Dear

Ihave macro below i want to run this when i enter data in cell "D10"
please help

Sub macro2()

Dim varAnswer As String
varAnswer = MsgBox("please insure that all data is i
thousands?", vbYesNo, "Warning")
If varAnswer = vbNo Then
Exit Sub
End If


End Sub
 
I have a similar issue. I want to run one of my macros based on conditional
results of a formula. For example, if cell XXXX is TRUE, then run macro,
else don't. I was searching help file, but I can't see refernce to VB code
that will run based on cell value or a formula that I can enter to activate
said macro. Help please....

Thanks,
Daryl Balcom
Honeywell
 
Thanks. I tried to do that (actually using D10) and it wouldn't call my
macro when I entered something in the cell. The macro works independently,
but not through the code you provided. I added it to the VB code of my macro.
I just made a silly macro to try out the function:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.count > 1 Then Exit Sub
If Not Intersect(Target, Range("D10")) Is Nothing Then
MsgBox "This is" & Target.Address
Call TEST
End If
End Sub


Sub TEST()
'
' TEST Macro
' Macro recorded 11/26/2008 by Honeywell
'

'
Range("E1").Select
ActiveCell.FormulaR1C1 = "TEST"
Range("E2").Select
End Sub
 
Your posted code works for me when I change D10.

But if D10 is a calcualted value of TRUE or FALSE you need a calculate
event, not a change event.

Private Sub Worksheet_Calculate()
If Me.Range("D10").Value = -1 Then '-1 is TRUE, 0 is FALSE
Call TEST
End If
End Sub

Sub TEST()
'
' TEST Macro
' Macro recorded 11/26/2008 by Honeywell
'

'
Range("E1").Select
ActiveCell.FormulaR1C1 = "TEST"
Range("E2").Select
End Sub


Gord Dibben MS Excel MVP
 
Back
Top