+ Reply to Thread
Results 1 to 5 of 5

Macro to enter calculation in cells adjacent to cells with values?

Hybrid View

  1. #1
    Registered User
    Join Date
    10-28-2009
    Location
    California, USA
    MS-Off Ver
    Excel 2011 (Mac)
    Posts
    39

    Macro to enter calculation in cells adjacent to cells with values?

    Hi all -

    I'm a rookie with macros and could really use some help.

    This workbook is constantly exported from our accounting system. I currently have a macro under personal that the accountant can run to delete the unnecessary columns, but I would like to add another automation -

    I need to divide each cell in column G by the cell in column E in that same row, then put the answer in column H of that same row. The first entry will always start in row 5, but the last entry is always unknown.

    Any help would be great! Thanks!
    Last edited by Samba1; 04-24-2010 at 03:23 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Marco to enter calculation in cells adjacent to cells with values?

    Something like:

    Dim LR as Long
    
    LR = Range("G" & Rows.Count).End(xlUp).Row
    
    With Range("H2:H" & LR)
        .FormulaR1C1 = "=RC7/RC5"
        .Value = .Value
    End With
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,523

    Re: Marco to enter calculation in cells adjacent to cells with values?

    Try this
        Range(Range("H5"), Range("G65536").End(xlUp).Offset(0, 1)) = "=IF(ISERROR(RC[-1]/RC[-3]),"""",RC[-1]/RC[-3])"

  4. #4
    Registered User
    Join Date
    10-28-2009
    Location
    California, USA
    MS-Off Ver
    Excel 2011 (Mac)
    Posts
    39

    Re: Macro to enter calculation in cells adjacent to cells with values?

    Worked perfect! Thank you both!

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro to enter calculation in cells adjacent to cells with values?

    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

+ 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