+ Reply to Thread
Results 1 to 10 of 10

Incorporate an Excel Formula in to this Macro

  1. #1
    Registered User
    Join Date
    09-23-2008
    Location
    Yokosuka Japan
    Posts
    44

    Incorporate an Excel Formula in to this Macro

    Hello,

    I am currently working on a project that will track personnel while they are waiting for inter-department transfers. Once they have been waiting for 90 days we have to notify our manager for further instructions.

    I have a button located in the upper left hand corner that when pressed activates the macro (launches a dialogue box for user data entry). I want to use two separate Excel Formula in the macro but I can't seem to get them to work. I want the formulas in the macro not in the cell because I know that in time someone will select an entire row and press delete, thus taking away the cell formatting/formula. I have been able to make some progress but cant find the correct syntax for the formulas.

    I have looked through the forum library for guidance (i.e. examples) before asking my question but wasn't able to quite find what I was looking for. Any help with this would be great. Thanks.

    Here is a copy of my code:

    Please Login or Register  to view this content.
    The formulas that I am trying to use are as follows:

    Task 1: In Column(K3) titled "Release Date" I need to add the value of +90 days based on the date value entered in Column(G3) titled "Qualified Date". I tried in the cell K3 =G3+90 and I get the desired results but I would like it to be part of the macro itself.

    Task 2: In Column(L3) titled "Hold/Release" I want to use the IF Function.
    I tried the following formula:
    =IF(K3<=TODAY(),"Release",IF(K3>=TODAY(),"Hold"))
    It works in the cell but I would like to have it work as part of the macro.

    Thank You for your time and excellence.

    Please see attachment.
    Attached Files Attached Files
    Last edited by BusDriver2; 04-14-2009 at 10:11 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Incorporate an Excel Formula in to this Macro

    Hello BusDriver2,

    I made a few changes to your "OK" command button code. It will now transfer the data from the User Form to the next empty line on your database worksheet. This macro has already been changed in the attached workbook.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    09-23-2008
    Location
    Yokosuka Japan
    Posts
    44

    Re: Incorporate an Excel Formula in to this Macro

    Hi Leith,

    Thanks for the speedy response and input on the "Ok Button", works like a champ now.

    Got any ideas for incorporating the excel formulas in to the macro itself?

    Again Thanks, Hope you had a nice Easter.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Incorporate an Excel Formula in to this Macro

    Hello BusDriver2,

    I had a good Easter. How about you?

    If it is okay with you, I'll work on the formula additions after I get some sleep. Oyasumi nasai.

  5. #5
    Registered User
    Join Date
    09-23-2008
    Location
    Yokosuka Japan
    Posts
    44

    Re: Incorporate an Excel Formula in to this Macro

    I had a nice Easter as well...

    Thanks for your help, I will tune in tmrw...

    Mata Ne...

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Incorporate an Excel Formula in to this Macro

    Hello BusDriver2,

    Here is the code for the updated macro. This now adds the formulas to the cells when the data is transferred to the worksheet.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    09-23-2008
    Location
    Yokosuka Japan
    Posts
    44

    Re: Incorporate an Excel Formula in to this Macro

    Leith,

    Wow, Thanks, This is great...

    I have noticed that if I call up the dialogue box and input data, click the "Okay" button, then the "Clear" button to create a new entry I get strange results.

    Example Given:
    1) make an entry
    2) clear button
    3) now 123 Type (pull down box): will contain not only contain the original choices but repeats...

    Frank-O
    Food
    Hello

    will become

    Frank-O
    Food
    Hello
    Frank-O
    Food
    Hello

    and each time you make an entry without closing the dialogue box it will add more Frank-o, Food, Hello...

    Is there some way to remedy this repetition?

    Other than that this thing is great. Thanks.

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Incorporate an Excel Formula in to this Macro

    Hello BusDriver2,

    I was so focused on the original request that I didn't check out the clear function. Gomen nasai yo! I'll check it out right now.

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Incorporate an Excel Formula in to this Macro

    Hello BusDriver2,

    That was easy. I created a macro called InitForm based on the code you had in the UserForm_Iniitalize() event module and added Clear methods to each ComboBox. Here is the macro and the other code changes...
    Please Login or Register  to view this content.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    09-23-2008
    Location
    Yokosuka Japan
    Posts
    44

    Re: Incorporate an Excel Formula in to this Macro

    Awesome, Awesome, Awesome, Awesome... A Metric Ton of Thanks to you Leith... you are truly Honto Tensai ... works great!!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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