Macro for autocalculate based on text in cell

maheshrk81

Board Regular
Joined
Jan 5, 2010
Messages
153
Hi All,

I have an excel file with many tabs. I need a macro to AutoCalculate only few sheets based on text in cell.
Need a macro to turn On/Off autocalculate based on text in cell.

If a text in Cell is "ABC" then i need sheet1, sheet5, sheet6 and sheet9 need to Calculate and rest all sheets should not calculate.
If a text in Cell is "MNO" then i need sheet4, sheet7, sheet6 and sheet9 need to Calculate and rest all sheets should not calculate.
If a text in Cell is "XYZ" then i need sheet10, sheet11, sheet6 and sheet9 need to Calculate and rest all sheets should not calculate.

Can someone help me.

Thanks in Advance.

Mahi
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Sorry, missed to inform the Main Sheet name.

In "Main" Sheet Cell A2 If the text is as below

If a text in Cell is "ABC" then i need sheet1, sheet5, sheet6 and sheet9 need to Calculate and rest all sheets should not calculate.
If a text in Cell is "MNO" then i need sheet4, sheet7, sheet6 and sheet9 need to Calculate and rest all sheets should not calculate.
If a text in Cell is "XYZ" then i need sheet10, sheet11, sheet6 and sheet9 need to Calculate and rest all sheets should not calculate.


Thanks in Advance.
Mahi​
 
Upvote 0
This is the non-elegant way to approach it, but should work
Code:
Sub CalculateSheets()
    Select Case Worksheets("Main").Range("A2").Value 'change to whatever
        Case "ABC"
            Worksheets("Sheet1").Calculate
            Worksheets("Sheet5").Calculate
            Worksheets("Sheet6").Calculate
            Worksheets("Sheet9").Calculate
        Case "MNO"
            Worksheets("Sheet4").Calculate
            Worksheets("Sheet6").Calculate
            Worksheets("Sheet7").Calculate
            Worksheets("Sheet9").Calculate
        Case "XYZ"
            Worksheets("Sheet6").Calculate
            Worksheets("Sheet9").Calculate
            Worksheets("Sheet10").Calculate
            Worksheets("Sheet11").Calculate
    End Select
End Sub

Your have your calculation set to manual, right?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,237
Messages
6,170,928
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top