+ Reply to Thread
Results 1 to 17 of 17

VBA for if statement and increment integer after macro runs to ensure it doesn't repeat

  1. #1
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,283

    VBA for if statement and increment integer after macro runs to ensure it doesn't repeat

    Hi All

    I have the below code that needs a tweak. I need to add a part that allows for a increment that will not allow LKey to be called again after it has been called.So once LKey has been called, Make LKI = 2. My brain is mush right now and can't figure it out.

    Please Login or Register  to view this content.
    Where and how can I insert the following code to make this work...LKey calls a userform which lets the operator enter a licence key. So once he enters licence key, the code must not ask him aain to do so. I hope this makes sense.
    Please Login or Register  to view this content.

  2. #2
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: VBA for if statement and increment integer after macro runs to ensure it doesn't repea

    Hello sintek,

    Just wondering, what would you like to happen if the procedure/code is called more than once, or twice on the same day?

    Should your LKI respond with every instance, or do you want it to remain "as is" after the initial change?


    Regards.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  3. #3
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,283

    Re: VBA for if statement and increment integer after macro runs to ensure it doesn't repea

    Hi Winon

    Thanks for response.... The code must be called once if condition is met, then something must happen so that the code is not called again.
    the procedure could be called up to 10 times in a day, so I don't want to have to insert a licence key all the time. Licence key must be inserted once and then something must ensure that it does not need to be inserted again..

    LKI must change after initial event so that the condition is not met again

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,283

    Re: VBA for if statement and increment integer after macro runs to ensure it doesn't repea

    Perhaps I can explain in more detail without code.

    If Day = Today and licence key has been entered then
    show a userform
    Elseif
    Day = Today and licence key has not been entered then
    Enter Licence Key
    Show Userform
    End If

  5. #5
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: VBA for if statement and increment integer after macro runs to ensure it doesn't repea

    Thank you for the clarification sintek,

    Where does the license key get entered into?

    there are so many other factors at play here, that I (again) would like to ask you to rather attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

    Thank you.

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,283

    Re: VBA for if statement and increment integer after macro runs to ensure it doesn't repea

    Thanks Winon

    Here you go...

    Press [1]
    Press [ADMIN]
    Enter [1] in first box [2] in second box
    Press [Enter]

    The licence key has now been activated so when i log in again, I do not want the Licence key UserForm to come up again.
    Attached Files Attached Files

  7. #7
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: VBA for if statement and increment integer after macro runs to ensure it doesn't repea

    This is going to take a bit of time, sintek.

    A quick fix? No. I'll sort it out for you in the morning.

    Good night,

    W

  8. #8
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,283

    Re: VBA for if statement and increment integer after macro runs to ensure it doesn't repea

    You are a star...sweet dreams..

  9. #9
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: VBA for if statement and increment integer after macro runs to ensure it doesn't repea

    Here you go sintek,

    The license key is valid for one day only. Each new day will require the License Key to be entered.

    It was quite a job with half a Workbook bombing out on me many a time, while trying to make it work, because of other controls and Code removed.

    Maybe it would be a good idea to copy me with your Complete Workbook and Code, to make it easier for me with any further help you may require.

    Kind Regards.
    Attached Files Attached Files

  10. #10
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,283

    Re: VBA for if statement and increment integer after macro runs to ensure it doesn't repea

    Morning Winon

    You are seriously a life saver....It works perfectly. I will most definately be able to edit for my purposes. I now know what you meant in an earlier thread that one does not need userforms etc for a POS system.

    Have a fantastic day and once again Thanks so much.

  11. #11
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: VBA for if statement and increment integer after macro runs to ensure it doesn't repea

    Post duplicated and deleted
    Last edited by Winon; 10-03-2016 at 03:47 AM.

  12. #12
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: VBA for if statement and increment integer after macro runs to ensure it doesn't repea

    A heartily Good Morning to you as well sintek,

    You are welcome, glad I could help a bit, and also thank you for adding to my Reputation. it is Much appreciated.

    Mooi dag vir jou ook! (Hope you understand Afrikaans)

    Kind regards.

    P.S. Any nice recipe for a nice bun for breakfast?

  13. #13
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,283

    Re: VBA for if statement and increment integer after macro runs to ensure it doesn't repea

    Hi Winon

    Well deserved I might add. Ja, ek is tweetalig. My culinary skills are limited lol...Can cook, but not a Chef. Always left that to the Kitchen Staff.

    Herewith code that works amazingly.

    Please Login or Register  to view this content.

  14. #14
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: VBA for if statement and increment integer after macro runs to ensure it doesn't repea

    Hi sintek,

    Herewith code that works amazingly.
    Sorry sintek, I have lost you somewhere along the lines!

    Which CommandButton2 where?, I don't seem to be able to apply it to what I have of the trimmed Workbook.

    Would you please be so kind as to enlighten me?

    Thanks.

  15. #15
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,283

    Re: VBA for if statement and increment integer after macro runs to ensure it doesn't repea

    Oops sorry

    CommandButton2 Is Admin Button...I changed the variables of the Sheet info manually to test all possible scenarios.
    Attached Files Attached Files

  16. #16
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: VBA for if statement and increment integer after macro runs to ensure it doesn't repea

    Wow, you are doing just Great, sintek!

    Thank you for the explanation, it was just in time to cancel my appointment with my Shrink.LOL!

    Phew, what a relief.

    Groete.

  17. #17
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,283

    Re: VBA for if statement and increment integer after macro runs to ensure it doesn't repea

    Ha Ha Must say...Without you all and this Forum, I'd be lost.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. If statement result runs a MACRO
    By danmazz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-03-2013, 12:16 PM
  2. [SOLVED] Ensure running a macro doesn't produce duplicate data
    By mhenry123 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-14-2013, 09:33 PM
  3. [SOLVED] Event macro runs in wrong workbook/doesn't work properly
    By VBA FTW in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-30-2012, 11:28 AM
  4. [SOLVED] Macro runs perfectly, but dialog box doesn't close automatically
    By Bunnyla in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-29-2012, 01:12 PM
  5. How to ensure the VBA code runs in the current XLS
    By singhabhijitkumar in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-18-2010, 04:20 AM
  6. Script works in Debugger but doesn't when Macro runs
    By sqeekypotato in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-02-2009, 11:31 AM
  7. Macro doesn't repeat manual actions
    By ddartt in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-12-2008, 05:43 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1