Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default macro to run only under certain condition - how?

I've written some code and assigned it to a command button (not the
ActiveX one), which works fine.
It adds a new dataset to a database, once the new information entered
is not part of the database yet.

Is there any way to disable the macro from running, once this newly
entered information is already stored in the database?

Basically I need some code for this:

If G6="not defined yet" then run the macro code
otherwise not

Thanks for your help!

Norbert

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default macro to run only under certain condition - how?

Norbert,

One way to do it would be to add a test at the start of the button code that
tests whether the condition has already been met, and exit if true.

I cannot be more specific than that as I do not know what your button code
looks like, or how you determine that the dataeset has already been added,
but you should know that.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Orion" wrote in message
...
I've written some code and assigned it to a command button (not the
ActiveX one), which works fine.
It adds a new dataset to a database, once the new information entered
is not part of the database yet.

Is there any way to disable the macro from running, once this newly
entered information is already stored in the database?

Basically I need some code for this:

If G6="not defined yet" then run the macro code
otherwise not

Thanks for your help!

Norbert



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default macro to run only under certain condition - how?

Hi Bob,
I also thought of adding a test at the start of the button code, but I
really don't know how. I'm still a very basic VB user. All I can do is
to record macros and fiddle a little bit about them.

The area to enter new information is 3 cells (B6:D6), which entries I
concatenate and vlookup in the database (patterns!G:H) for existency.

Formula in G6:
=IF(ISERROR(VLOOKUP(CONCATENATE(B6,C6,D6),patterns !G:H,2,FALSE)),"not
defined yet",VLOOKUP(CONCATENATE(B6,C6,D6),patterns!G:H,2, FALSE))

when the entry exists, I get back the previously allocated Pattern
number,
once the entry doesn't exist, I get back the message "not defined yet"

I can see on the result, if the pattern exists or not, so I (with
stress on "I") know, when not to press the button, but the user I'm
writing the spreadsheet for, might not and I have to avoid same
entries with different allocated Pattern numbers (which will be given
in consecutive order for newly entered datasets).


this is my button code:
Sub INPUT_PATTERN()
'
Application.ScreenUpdating = False
Sheets("patterns").Select
Cells.Select
Selection.EntireColumn.Hidden = False
Columns("A:A").Select
Selection.EntireColumn.Hidden = True
Range("B8:H8").Select
Selection.Copy
Selection.Insert Shift:=xlDown
Range("C8:E8").Select
Application.CutCopyMode = False
Selection.ClearContents
Range("H8").Select
Selection.ClearContents
Range("B2:H2").Select
Selection.Copy
Range("B8").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
True, Transpose:=False
Application.CutCopyMode = False
Application.Run "'conversion.xls'!SORT_FABRICS"
Range("B:B,G:G").Select
Range("G1").Activate
Range("C7").Select
Selection.EntireColumn.Hidden = True
Sheets("CONVERSION").Select
End Sub

Hope You can help me now.

Regards,
Norbert



On Wed, 22 Dec 2004 09:38:01 -0000, "Bob Phillips"
wrote:

One way to do it would be to add a test at the start of the button code that
tests whether the condition has already been met, and exit if true.

I cannot be more specific than that as I do not know what your button code
looks like, or how you determine that the dataeset has already been added,
but you should know that.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Orion" wrote in message
.. .
I've written some code and assigned it to a command button (not the
ActiveX one), which works fine.
It adds a new dataset to a database, once the new information entered
is not part of the database yet.

Is there any way to disable the macro from running, once this newly
entered information is already stored in the database?

Basically I need some code for this:

If G6="not defined yet" then run the macro code
otherwise not

Thanks for your help!

Norbert



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
Delete Macro with OR/ELSE condition Mike Excel Discussion (Misc queries) 5 January 11th 10 09:08 PM
Macro if condition puiuluipui Excel Discussion (Misc queries) 5 November 13th 09 12:07 PM
use more than 4 condition in cf without using macro Montu Excel Worksheet Functions 3 November 15th 07 03:19 PM
event macro on a condition TUNGANA KURMA RAJU Excel Discussion (Misc queries) 2 December 19th 05 07:15 AM
How Do I Hide A Row (if a condition is true) using a Macro ? Anthony Fantone Excel Worksheet Functions 1 June 16th 05 04:54 PM


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