+ Reply to Thread
Results 1 to 27 of 27

Convert Formulas to VBA Code

  1. #1
    Registered User
    Join Date
    04-28-2015
    Location
    bangalore
    MS-Off Ver
    2013
    Posts
    56

    Question Convert Formulas to VBA Code

    Dear Experts,

    Kindly Convert the below formulas to VBA code.

    Sheet1 having morethan 25000 lines. Please help me its very urgent.

    =IF(BT3=AI3,"CURRENT MONTH","CATCHUP/CATCHDOWN").............Values in (AK3)
    =IF(CB3<0,0,IF(CB3>1,1,CB3))........ ...................Values in (AL3)
    =IF(ISERROR((AL3/CD3)*MIN(CF3,CG3,CE3)),0,((AL3/CD3)*MIN(CF3,CG3,CE3))) .............Values in (AM3)
    =IF(BZ3="CURRENT MONTH",IF(AL3<0,0,AL3),0)............................................Values in (AN3)
    =IF(CC3=0,0,SUMIF(A:A,A3,CC:CC)).......................................................Values in (AO3)
    =IF(BZ3="CURRENT MONTH",IF(C3<$CG$1,100%,IF(ISERROR((D3-C3)/($CG$2-$CG$1)),100%,((D3-C3)/($CG$2-$CG$1)))),0)....Values in (AP3)
    =IF(BZ3="CURRENT MONTH",IF(C3<$CG$1,100%,($CG$2-C3)/($CG$2-$CG$1)),0) ...............................Values in (AQ3)
    =IF(BZ3="CURRENT MONTH",IF(D3="NULL",100%,IF(D3>$CG$2,100%,(D3-$CG$1)/($CG$2-$CG$1))),0)...............Values in (AR3)
    =IF(BZ3="CURRENT MONTH",IF(OR(AO3="NULL",AO3=100633,AO3=104857,AO3=100634),0,AL3),0) ..............Values in (AW3)
    =IF(BZ3="CURRENT MONTH",AK3,0) .................................................................Values in (AT3)
    =IF(BZ3="CURRENT MONTH",SUMIF(A:A,A3,CH:CH),0) ............................Values in (AU3)
    =IF(BZ3="CURRENT MONTH",SUMIF(A:A,A3,CI:CI),0) .........................................Values in (AV3)
    =IF(OR(CH3=0,AV3="company",BM3="Level 9",BM3="Level 10",BM3="Level 11",CJ3<80),"-",IF(CK3=0,"Buffer","-")).............Values in (AW3)
    =IF(CL3="Buffer",CA3,0) ........................................................Values in (AX3)
    =IF(OR(BM3="level 1",BM3="level 2"),CA3,0)..................................Values in (AY3)

    Thanks,

    Kumar
    Last edited by KumarPK; 04-29-2015 at 01:10 AM.

  2. #2
    Forum Contributor LokeshKumar's Avatar
    Join Date
    03-31-2015
    Location
    India
    MS-Off Ver
    All, mostly 2010 now..
    Posts
    471

    Re: Convert Formulas to VBA Code

    Hi,
    Your requirement is not clear....you can not convert this to VBA code.....but you can do something in VBA so that output will remain same....
    Lokesh Kumar
    Stay Hungry.. Stay Foolish..
    _________________________________________________________
    Please Click STAR to Add Reputation if my/someone's answer helped!

  3. #3
    Forum Contributor
    Join Date
    09-30-2009
    Location
    Barcelona
    MS-Off Ver
    Excel 2010
    Posts
    274

    Re: Convert Formulas to VBA Code

    you want to set formulas by vba code?
    calculate by vba and paste the only the result?

    it might be better to calculate the formula and then copy-paste values. I do it all the time.
    you should rewrite the formulas to use named ranges, so that the formula is exactly the same in all rows.

    then you can leave formulas in a auxiliary row (at the top of the sheet for instance) and then just copy the formula to the full column.

    fullcolumnRange.formula = auxRowcell.formula

    and then to convert to values you can just do

    fullcolumnrange.value = fullcolumnrange.value

    as long as no errors appear as result. Otherwise you can do copy, and pastespecial xlpastevalues of fullcolumnrange


    HTH

  4. #4
    Registered User
    Join Date
    04-28-2015
    Location
    bangalore
    MS-Off Ver
    2013
    Posts
    56

    Re: Convert Formulas to VBA Code

    Hi Bagullo,

    Yes, I want to set formulas by vba code. I am just learning VBA and not familier with codes.


    I have already created a command button to run this codes.


    Please write the codes......

    Thanks

    Kumar

  5. #5
    Registered User
    Join Date
    04-28-2015
    Location
    bangalore
    MS-Off Ver
    2013
    Posts
    56

    Re: Convert Formulas to VBA Code

    Hi Experts,

    Yes, I want to set formulas by vba code. I am just learning VBA and not familier with codes.


    I have already created a command button to run this codes.


    Please write the codes......

    Thanks

    Kumar

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Convert Formulas to VBA Code

    Maybe?

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    04-20-2015
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    17

    Re: Convert Formulas to VBA Code

    Quote Originally Posted by KumarPK View Post
    Hi Experts,

    Yes, I want to set formulas by vba code. I am just learning VBA and not familier with codes.


    I have already created a command button to run this codes.


    Please write the codes......

    Thanks

    Kumar
    Hello Kumar,

    It will be easier for us to write the code if we actually know what kind of input you are placing in the cells. Is it possible for you to share the excel that you currently have using these formulas?

  8. #8
    Registered User
    Join Date
    04-28-2015
    Location
    bangalore
    MS-Off Ver
    2013
    Posts
    56

    Re: Convert Formulas to VBA Code

    Hi John, Thank you so much for reply, I have pasted your code but its not working.( There is no error msg also).

    I m trying to upload the xl file, but its not uploading.

    The base data contains in Sheet1

    Let me know if any more information.


    Thanks

    Kumar.

  9. #9
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Convert Formulas to VBA Code

    I can't see why it doesn't work, unless I misunderstood? However, if you load the sample, then I could test it too see. BTW Sheet1 should be active before running the code.

  10. #10
    Registered User
    Join Date
    04-28-2015
    Location
    bangalore
    MS-Off Ver
    2013
    Posts
    56

    Re: Convert Formulas to VBA Code

    John, Is there any other way to upload the sample file...

    I am trying to upload but Its not uploading( File size is 21kb)

    This is my first question and First time I have entered into this forum.

    Please help me..


    Thanks

    Kumar

  11. #11
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Convert Formulas to VBA Code

    You don't need to upload the entire file if it is too large. Just create a sample with 50 lines or less for us to test on.

  12. #12
    Registered User
    Join Date
    04-28-2015
    Location
    bangalore
    MS-Off Ver
    2013
    Posts
    56

    Re: Convert Formulas to VBA Code

    John, I have added only 20 lines but its not uploading..is there any other way to upload...??

  13. #13
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Convert Formulas to VBA Code

    Scroll down towards the bottom of this thread and click the button Go Advanced - then scroll down to the Manage Attachments button, browse to the required file, and then push the Upload button and click Done.

  14. #14
    Registered User
    Join Date
    04-28-2015
    Location
    bangalore
    MS-Off Ver
    2013
    Posts
    56

    Re: Convert Formulas to VBA Code

    John,

    My badluck its not upload, I have followed your procedure, its taking longtime to upload , still its not upload.

    Shall I send mail to you... if Yes... Please provide your email ID..


    Thnx
    Kumar

  15. #15
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Convert Formulas to VBA Code

    See my PM.

  16. #16
    Registered User
    Join Date
    04-28-2015
    Location
    bangalore
    MS-Off Ver
    2013
    Posts
    56

    Re: Convert Formulas to VBA Code

    Hi John,

    I have sent the Sample XL file to your mail box.


    Pls do the needful.

    Thanks

    Kumar

  17. #17
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Convert Formulas to VBA Code

    Try:

    Please Login or Register  to view this content.
    For your sample.

  18. #18
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Convert Formulas to VBA Code

    I added a module, revised your range and included it in the attachment.
    Attached Files Attached Files

  19. #19
    Registered User
    Join Date
    04-28-2015
    Location
    bangalore
    MS-Off Ver
    2013
    Posts
    56

    Re: Convert Formulas to VBA Code

    Working perfectly....................Wow John its great.... Appreciate your Fabulous job.. you made my day.... God Bless..

    John & Excel Forum Thank you so much

  20. #20
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Convert Formulas to VBA Code

    You're welcome. Glad to help out and thanks for the feedback. Please comply with Forum Rules and mark this thread as SOLVED. See link below for guidance.

    http://www.excelforum.com/forum-rule...rum-rules.html

  21. #21
    Registered User
    Join Date
    04-28-2015
    Location
    bangalore
    MS-Off Ver
    2013
    Posts
    56

    Re: Convert Formulas to VBA Code

    Hi John, Sorry for the disturbance...

    Again we have some challenging inputs....I feel this is piece of cake for you..

    1.
    When I pulled the data from the system the date show is custom value and its not in proper way.
    We are manually replacing the data with Correct date format in the following columns.

    Column - Range C:D
    Column - Range H:I
    Column - Range BR:BS

    I request this needs to be replaced with correct date format from Custom to Date format.

    2.
    There is a blank cells when we pulled the data from Range A:BY.
    This should be replace with Null instead of blanks


    I have sent the XL file for your mail box due to unable to upload the file in forum.

    I request you to please do the needful.

    Thanks

    Kumar

  22. #22
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Convert Formulas to VBA Code

    Try:

    Please Login or Register  to view this content.

  23. #23
    Registered User
    Join Date
    04-28-2015
    Location
    bangalore
    MS-Off Ver
    2013
    Posts
    56

    Re: Convert Formulas to VBA Code

    John,

    Thanks for reply.
    Everything working fine but only Column "D" instead of Null its filling up the timings for blank cells. I have marked in Yellow.


    Rest everything is file.



    Thanks



    Kumar

  24. #24
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Convert Formulas to VBA Code

    OK Try:

    Please Login or Register  to view this content.

  25. #25
    Registered User
    Join Date
    04-28-2015
    Location
    bangalore
    MS-Off Ver
    2013
    Posts
    56

    Re: Convert Formulas to VBA Code

    WOW.........Working Perfectly. This is I was looking for...

    Thank you so much John... Have a wonderful day...

    Thnx
    KumarPK

  26. #26
    Registered User
    Join Date
    04-28-2015
    Location
    bangalore
    MS-Off Ver
    2013
    Posts
    56

    Re: Convert Formulas to VBA Code

    Excellent.... SOLVED

  27. #27
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Convert Formulas to VBA Code

    Once again welcome. Please comply with Forum Rules and mark this thread as SOLVED. See link below for guidance.

    http://www.excelforum.com/forum-rule...rum-rules.html

+ 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. vba code to convert formulas into text.
    By winmaxservices1 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-05-2015, 04:31 AM
  2. Convert Cell Formula to Convert Text to VBA Code
    By PY_ in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-08-2014, 05:51 PM
  3. code to add formulas to a range with previous formulas appearing inside the new one
    By Excel-o-ratoR in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-07-2010, 06:02 AM
  4. Convert formulas in text into formulas
    By Tau in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 12-13-2007, 08:31 AM
  5. Replies: 0
    Last Post: 05-10-2005, 04:06 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