#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default macro

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default macro


Put this in the worksheet code module

*Private Sub Worksheet_Change(ByVal Target As Range)
If target.cells.count 1 then exit su
If Not Intersect(Target, Range("D10")) Is Nothing The
MsgBox "This is" & Target.Addres
'Call Macro2 ''uncomment this to run your cod
End I
*End Sub

--
Simon Lloy

Regards
Simon Lloy
'The Code Cage' (http://www.thecodecage.com
-----------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=
View this thread: http://www.thecodecage.com/forumz/showthread.php?t=3413

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default macro

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

"Simon Lloyd" wrote:


Put this in the worksheet code module:

*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 Macro2 ''uncomment this to run your code
End If
*End Sub*


--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=34136


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default macro


The code supplied works only when D10 is changed, you can use the same
principle.


--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=34136

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default macro

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



"Simon Lloyd" wrote:


The code supplied works only when D10 is changed, you can use the same
principle.


--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=34136




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default macro

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


On Wed, 26 Nov 2008 13:36:01 -0800, Daryl - Honeywell
wrote:

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



"Simon Lloyd" wrote:


The code supplied works only when D10 is changed, you can use the same
principle.


--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=34136



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default macro


Gordon i realised i should have mentioned that to the OP shortly after
posting! ;)


--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=34136

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Need syntax for RUNning a Word macro with an argument, called from an Excel macro Steve[_84_] Excel Programming 3 July 6th 06 07:42 PM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 01:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"