Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Delete Macro with OR/ELSE condition | Excel Discussion (Misc queries) | |||
Macro if condition | Excel Discussion (Misc queries) | |||
use more than 4 condition in cf without using macro | Excel Worksheet Functions | |||
event macro on a condition | Excel Discussion (Misc queries) | |||
How Do I Hide A Row (if a condition is true) using a Macro ? | Excel Worksheet Functions |