+ Reply to Thread
Results 1 to 11 of 11

fill row with formula

Hybrid View

  1. #1
    Registered User
    Join Date
    01-30-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    17

    fill row with formula

    Hello,

    I have a macro that add rows and I fill them with data.
    I want to insert to onw of the rows a formula so it will be available in the added rows.

    the formula is:

    =IF(E9="שבת","00:00",IF(K9-J9<0,"00:00",K9-J9))
    any idea?

    Thanks

  2. #2
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: fill row with formula

    just assign the desired cell with the formula

    for example if the column is 20 and the row is newrow

    cell(newrow,20)="=IF(E9="שבת","00:00",IF(K9-J9<0,"00:00",K9-J9))"

  3. #3
    Registered User
    Join Date
    01-30-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: fill row with formula

    Hey,
    Thanks for your replay.

    I have 2 problems with your example:
    1. E9 is a row which I copied the formula from but I use this formula in every row in that column. so, the new row will be E_ (the number of the row which I dont know)
    2. its returns me an error : "syntax error"

    I will explain again what I want to do.
    I'm calculating the sum of the values in each row in that column. I used this formula because I have raws without value so I wanted to insert 0 so it wont return an error. so the point is that I want to enter the value that the user will enter in the new row that have been added by the macro to the sum calculation.

  4. #4
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: fill row with formula

    Yes I see the problem,

    One way to overcome that is using the indirect reference. could you set up a sample and I will set up the appropiate formula to populate the cell correctly.

  5. #5
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: fill row with formula

    ActiveCell.FormulaR1C1 = "=IF(RC[-15]=""???"",""00:00"",IF(RC[-9]-RC[-10]<0,""00:00"",RC[-9]-RC[-10]))"

  6. #6
    Registered User
    Join Date
    01-30-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: fill row with formula

    How can I upload a file here?

  7. #7
    Registered User
    Join Date
    01-30-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: fill row with formula

    What does R1C1 means? and wy RC[-15]...?

  8. #8
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: fill row with formula

    this is a different way of entering formulae.

    did you try it?
    R1C1 format means that you Row 1 Column 1.
    RC[-15]. If your formula were in row 1. column 20 then this would be looking at the same row but 15 columns to the left.

    get your macro to put this formul;a into your spreadsheet. it will work

  9. #9
    Registered User
    Join Date
    01-30-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: fill row with formula

    Hello,
    Thanks for your reply.
    I need the formula to be at each row at the same column so I need it to look for example at the same column but 10 rows up.
    How can I do that?

  10. #10
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,685

    Re: fill row with formula

    attach the dummy file.

  11. #11
    Registered User
    Join Date
    01-30-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: fill row with formula

    Hello,

    I've attached a sample file with macro.

    Thanks for your help
    Attached Files Attached Files

+ 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