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

I am trying to start a macro on the condition of a cell. For example when
A7=10 it starts the macro and runs it through once.
Regards Dave
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 896
Default Starting macro

Sub Macro1()
If Range("A7").Value = 10 Then
Call Macro2
End If
End Sub

this Macro1 starts Macro2 based on your condition

pls click YES if it helped


On 2 Cze, 08:56, Davidm wrote:
I am trying to start a macro on the condition of a cell. For example when
A7=10 it starts the macro and runs it through once.
Regards Dave


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Starting macro

You could use event code to run the macro.

How is the number in A7 derived? Manually or by formula?

Example code for a formula-derived result in A7. Edit to Worksheet_Change
if manually input.

Private Sub Worksheet_Calculate()
'Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo stoppit
Application.EnableEvents = False
With Me.Range("A7")
If .Value = 10 Then
Call macroname
End If
End With
stoppit:
Application.EnableEvents = True
End Sub


Gord Dibben MS Excel MVP

On Mon, 1 Jun 2009 23:56:01 -0700, Davidm
wrote:

I am trying to start a macro on the condition of a cell. For example when
A7=10 it starts the macro and runs it through once.
Regards Dave


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 20
Default Starting macro

Thanks, worked well
I will now be able to use this principal a lot

Dave

"Gord Dibben" wrote:

You could use event code to run the macro.

How is the number in A7 derived? Manually or by formula?

Example code for a formula-derived result in A7. Edit to Worksheet_Change
if manually input.

Private Sub Worksheet_Calculate()
'Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo stoppit
Application.EnableEvents = False
With Me.Range("A7")
If .Value = 10 Then
Call macroname
End If
End With
stoppit:
Application.EnableEvents = True
End Sub


Gord Dibben MS Excel MVP

On Mon, 1 Jun 2009 23:56:01 -0700, Davidm
wrote:

I am trying to start a macro on the condition of a cell. For example when
A7=10 it starts the macro and runs it through once.
Regards Dave



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
Starting A Macro zephyr Excel Discussion (Misc queries) 2 November 10th 06 12:03 PM
starting a macro at startup chip_pyp Excel Discussion (Misc queries) 1 March 22nd 06 06:59 PM
Returning Macro to Starting Cell sony654 Excel Worksheet Functions 3 February 25th 06 12:02 PM
Returning Macro to Starting Cell sony654 Excel Worksheet Functions 4 February 25th 06 12:46 AM
Starting a macro with the IF function THW Excel Worksheet Functions 4 June 19th 05 05:40 PM


All times are GMT +1. The time now is 02:10 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"