+ Reply to Thread
Results 1 to 3 of 3

Recalculate selcted rows based on a condition

  1. #1
    Registered User
    Join Date
    08-05-2021
    Location
    Bergen
    MS-Off Ver
    2017
    Posts
    2

    Recalculate selcted rows based on a condition

    Hi,

    I want to be able to control which calculations within a sheet that are being preformed based upon the necessity of recalculation set by a true/false condition in the form IF(>0;true;false).

    The sheet contains 8000 rows preforming the same calculation, but with 8000 different input conditions. However, based on separate input I only require somewhere between 500-1500 of these 8000 calculations to be updated. The idea is that this will save some time on the calulations, hence speeding up the program.

    Is it possible to write a macro in VBA that does this?

    Psuedo-code:

    IF Value in Column M, Row (j) >0
    Then recalculate Row(j)
    Else Do Nothing

    Secondly, will this actually save me some time on the total simulation?
    Note: In each row there are 53 colums of data being updated, some with IF, MAX, VBA UDFs etc. In addition to a loop which affects about 10 of columns.

    I hope my question was understandable and that someone can assist me. If additional specification is neccessary please let me know.

  2. #2
    Registered User
    Join Date
    03-10-2021
    Location
    Paryzevo
    MS-Off Ver
    2k3
    Posts
    60

    Re: Recalculate selcted rows based on a condition

    In contextual vba help we can find this:

    "Worksheet.Calculate Method
    To calculate:
    1. All open workbooks => Application.Calculate (or just Calculate)
    2. A specific worksheet => Worksheets(1).Calculate
    3. A specified range => Worksheets(1).Rows(2).Calculate

    Example: This example calculates the formulas in columns A, B, and C in the used range on Sheet1."

    Please Login or Register  to view this content.
    Try to put it into practice.

  3. #3
    Registered User
    Join Date
    08-05-2021
    Location
    Bergen
    MS-Off Ver
    2017
    Posts
    2

    Re: Recalculate selcted rows based on a condition

    I attempted to write a sub based upon your answer, however the intended functionality is not observed. Why this is so im not sure, but what i want from it is as mentioned to only update the values in the rows that meet the condition.

    Sub Calculate_Range()
    Dim i As Long
    For i = 4 To 8004

    If Sheets("Sheet1").Range(i, 13).Value > 0 Then

    Sheets("Sheet2").Rows(i).Calculate

    Next i
    End Sub

+ 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. Recalculate (F9) until condition met
    By mihaipir in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-02-2017, 08:10 AM
  2. Replies: 7
    Last Post: 02-04-2014, 05:49 AM
  3. VBA for msg box Ok & cancle buttong help & clear data between selcted rows
    By santosh226001 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-28-2012, 11:52 AM
  4. Recalculate until condition met
    By ab14 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-30-2012, 07:22 AM
  5. Replies: 1
    Last Post: 01-28-2011, 05:58 PM
  6. Recalculate sheet repeatedly until condition met
    By montreal1775 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-02-2008, 03:45 PM
  7. Recalculate on condition
    By DavidObeid in forum Excel General
    Replies: 3
    Last Post: 08-04-2006, 12:11 AM

Tags for this Thread

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