![]() |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
All times are GMT +1. The time now is 06:55 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com