+ Reply to Thread
Results 1 to 5 of 5

Calculate sum using VBA

  1. #1
    Forum Contributor
    Join Date
    04-21-2009
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    710

    Calculate sum using VBA

    Hi all, I have a macro which takes live data every second from Range P5 to P60 and pastes it into cells AA105 to AA160 - it then shifts the data already in AA105 to AA160 into AB104 to AB160 thus shifting everything to the right as per the code below

    Please Login or Register  to view this content.
    What I want to do in rows 205: 260 is calculate the difference between AB105:AB160 and AA105:AB160 as that moves along.

    Something like

    Range("AA205:AA260").Value = Range("AB105:AB160").Value - Range("AA105:AA160").Value

    Only the code above is not correct and I would like to know the correct way to do this. I hope I have explained it well enough

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,691

    Re: Calculate sum using VBA

    This will populate the formulas:

    Please Login or Register  to view this content.
    Did you want formulas or just values?
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Calculate sum using VBA

    Hi,

    Maybe something like

    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,691

    Re: Calculate sum using VBA

    This version takes my formula solution and adds turning the formulas into values. This is probably faster than doing all the arithmetic in VBA code:

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    04-21-2009
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    710

    Re: Calculate sum using VBA

    Thanks all, I will give them a try today and let you know how I get on

+ 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. Replies: 1
    Last Post: 01-07-2018, 10:30 AM
  2. Replies: 5
    Last Post: 06-11-2017, 01:51 AM
  3. [SOLVED] Formula: If cell 3 is blank have cell 1 calculate, if cell 3 filled have cell 2 calculate
    By Vicious00013 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 04-05-2016, 09:34 AM
  4. Code to Calculate the product of two matrices won't calculate
    By njrobby in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-05-2015, 01:37 AM
  5. Target.Calculate to Me.Calculate breaks Copy/Paste
    By vayana in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-27-2013, 10:36 AM
  6. [SOLVED] Calculate values in col B based on value in col B but only calculate final 5 instances
    By arnoldd99 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-04-2013, 11:53 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