Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hello, Is there a way that I can check to see if a macro was run from within that macro before it proceeds with a part of the macro, maybe have it check something before proceeding with the rest of it ? What I want it to do is stop someone from run a macro again if it was already ran, and if it wasn't ran before to check some column headings to make sure they are all there, before proceeding with the macro. Thanks -- snowing ------------------------------------------------------------------------ snowing's Profile: http://www.excelforum.com/member.php...o&userid=34576 View this thread: http://www.excelforum.com/showthread...hreadid=547810 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dim bMacro1WasRun as boolean
sub MySub() if bMacro1WasRun then <do something else <do whatever end if end sub sub Macro1 <do some stuff bMacro1WasRun = true end sub Et voilà -- AP "snowing" a écrit dans le message de news: ... Hello, Is there a way that I can check to see if a macro was run from within that macro before it proceeds with a part of the macro, maybe have it check something before proceeding with the rest of it ? What I want it to do is stop someone from run a macro again if it was already ran, and if it wasn't ran before to check some column headings to make sure they are all there, before proceeding with the macro. Thanks -- snowing ------------------------------------------------------------------------ snowing's Profile: http://www.excelforum.com/member.php...o&userid=34576 View this thread: http://www.excelforum.com/showthread...hreadid=547810 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Thanks for the help. Ardus can you explain your code a little for me, I would need something to work from within the one macro -- snowing ------------------------------------------------------------------------ snowing's Profile: http://www.excelforum.com/member.php...o&userid=34576 View this thread: http://www.excelforum.com/showthread...hreadid=547810 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() There are various ways of doing this but I think the easiest way is to use a cell on a worksheet (maybe a hidden sheet) to store an update/updated flag. Then use the workbook.open event to set the flag to "update". Before running the checking macro see if the is "update" Then when you run the macro which does the update reset the flag to "updated". Note that if you try and hold the flag as a variable it will get reset each time the code finishes. regards -- tony h ------------------------------------------------------------------------ tony h's Profile: http://www.excelforum.com/member.php...o&userid=21074 View this thread: http://www.excelforum.com/showthread...hreadid=547810 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Tony's solution is smarter because it saves the "MacroWasRun" status
You place a FALSE/TRUE value in some definite cell, then you test its contents. HTH -- AP "snowing" a écrit dans le message de news: ... Hello, Is there a way that I can check to see if a macro was run from within that macro before it proceeds with a part of the macro, maybe have it check something before proceeding with the rest of it ? What I want it to do is stop someone from run a macro again if it was already ran, and if it wasn't ran before to check some column headings to make sure they are all there, before proceeding with the macro. Thanks -- snowing ------------------------------------------------------------------------ snowing's Profile: http://www.excelforum.com/member.php...o&userid=34576 View this thread: http://www.excelforum.com/showthread...hreadid=547810 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Here is some code that does not use a cell for storage but one of th document properties - if necessary you can create a custom property The advantage of using one of these properties is that it does no inflict anything on the sheets themselves. Private Sub Workbook_Open() ThisWorkbook.BuiltinDocumentProperties("Comments") = "N" End Sub Sub mySub() If ThisWorkbook.BuiltinDocumentProperties("Comments") = "N" Then do my run once code then set ThisWorkbook.BuiltinDocumentProperties("Comments") = "" End If do my always code End Sub Cheers (and thanks Ardus -- tony ----------------------------------------------------------------------- tony h's Profile: http://www.excelforum.com/member.php...fo&userid=2107 View this thread: http://www.excelforum.com/showthread.php?threadid=54781 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Cannot verify XNPV with PV or HP-12C | Excel Worksheet Functions | |||
Verify email | Excel Discussion (Misc queries) | |||
Several Dates -Verify | Excel Worksheet Functions | |||
Verify names | Excel Programming | |||
Verify Totals | Excel Programming |