+ Reply to Thread
Results 1 to 11 of 11

Convert excel formula into macro

  1. #1
    Forum Contributor
    Join Date
    10-02-2012
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    165

    Convert excel formula into macro

    Hi,

    I have three sheet from which I need to populate date difference in sheet "Occupy sheet" based on below logic. I have already used the formula. How can this be converted into macro. Note that the row can be inserted dynamically.

    Also, for blank date, the formula display minus value. It should be blank

    date difference in col K= col J- col G
    date difference in col P= col O- col N
    Col Q contain formula as colQ= "=IF(P2 <=0, "on time", "Delayed")"
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Convert excel formula into macro

    Clean up last row and try

    Please Login or Register  to view this content.
    - Battle without fear gives no glory - Just try

  3. #3
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Convert excel formula into macro

    Another one perhaps better
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    10-02-2012
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    165

    Re: Convert excel formula into macro

    Thanks PCI for your great help.

    I am populating text "On time" and "Delayed" on column Q based on the data available in col P.

    If column P is blank, is it possible to display blank in stead of "on time" in col Q. It means blank should be populated for P2, P4 etc.

    --> "On time" should display it value less than or equal to zero

  5. #5
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Convert excel formula into macro

    Is it want you want ??
    Check and double check
    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Question Re: Convert excel formula into macro

    Quote Originally Posted by sarat47 View Post
    How can this be converted into macro.
    Hi !

    Easy to code just using the same Excel formulas but it depends on if you want formulas in cells or just their results ? …

  7. #7
    Forum Contributor
    Join Date
    10-02-2012
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    165

    Re: Convert excel formula into macro

    Thank you for your support.
    The macro is not working for second condition (col P= col O- col N) when new dates are added in the column "O".
    Difference in date is showing blank for row 5,6 and 7 which I have added as a sample in attached sheet.
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Just with Excel basics ! …


    As a beginner starter for column Q :

    PHP Code: 
    Sub Demo1()
        
    With Sheet2.UsedRange.Rows
            With 
    .Item("2:" & .Count).Columns
                 With 
    .Item(17)
                      .
    Formula "=IF(O2>N2,""Delayed"","""")"
                      
    .Formula = .Value
                 End With
            End With
        End With
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !

  9. #9
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066
    Quote Originally Posted by sarat47 View Post
    Hi,

    I have three sheet from which I need to populate date difference in sheet "Occupy sheet" based on below logic. I have already used the formula. How can this be converted into macro. Note that the row can be inserted dynamically.

    Also, for blank date, the formula display minus value. It should be blank

    date difference in col K= col J- col G
    date difference in col P= col O- col N
    Col Q contain formula as colQ= "=IF(P2 <=0, "on time", "Delayed")"
    Do you lau chef again the macro
    Do you want the macro to be fired when entering the data ?

  10. #10
    Forum Contributor
    Join Date
    10-02-2012
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    165
    Thanks PCI and Marc once again. Pci, Yes, if both column contain date, the macro should calculate days automatically for the second condition. The first condition is working perfectly. Only issue in 2nd one

  11. #11
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Convert excel formula into macro

    Not sure to have a clear understanding of your need but try next code
    For more details see file attached

    in a module put

    Please Login or Register  to view this content.
    In the sheet Occupy sheet 's code put

    Please Login or Register  to view this content.

+ 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. [SOLVED] Convert formula to macro
    By bigband1 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-24-2015, 06:07 PM
  2. [SOLVED] Convert excel macro to excel formula
    By Jovillanueva in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 01-20-2014, 01:45 AM
  3. convert excel formula into macro
    By abraham30 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-03-2013, 09:36 PM
  4. convert formula to macro.
    By superchew in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-05-2013, 08:31 PM
  5. convert macro into formula
    By busybeemg in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-07-2010, 02:45 PM
  6. Convert Excel Formula to Macro Code
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-28-2009, 10:14 PM
  7. need macro: convert formula to value
    By moshe in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-06-2005, 12:06 PM

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