Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Verify before proceeding


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


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

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


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

  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Verify before proceeding


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

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


The workbook_open module needs to be ThisWorkbook module (in VB
explorer VBAProject...Microsoft Excel Objects... ThisWorkbook)

The rest of the code in a standard module. Put some msgbox call in t
track what happens eg

Private Sub Workbook_Open()
ThisWorkbook.BuiltinDocumentProperties("Comments") = "N"
MsgBox "initialise"
End Sub



Sub mySub()
If ThisWorkbook.BuiltinDocumentProperties("Comments") = "N" Then
MsgBox "run once"
ThisWorkbook.BuiltinDocumentProperties("Comments") = ""
End If

MsgBox "do always"

End Sub

you should get "initialise" when you open the workbook. The other tw
should appear as you run mySu

--
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

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Verify before proceeding


Thanks Tony, works great.


--
snowing
------------------------------------------------------------------------
snowing's Profile: http://www.excelforum.com/member.php...o&userid=34576
View this thread: http://www.excelforum.com/showthread...hreadid=547810

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
Cannot verify XNPV with PV or HP-12C ncw Excel Worksheet Functions 4 May 9th 09 12:35 AM
Verify email Sandee Excel Discussion (Misc queries) 1 February 9th 05 04:01 PM
Several Dates -Verify zeek Excel Worksheet Functions 4 January 16th 05 01:31 PM
Verify names JJ Excel Programming 0 November 2nd 04 02:34 PM
Verify Totals Lynn[_5_] Excel Programming 0 August 17th 04 08:05 PM


All times are GMT +1. The time now is 02:46 PM.

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

About Us

"It's about Microsoft Excel"