Jim
Jim

Reputation: 1005

Only change values on active worksheet

I have a workbook with 4 sheets. The 4 sheets are almost identical Some of the cells values are calculated by calling a macro in the cell. For the active worksheet this Works fint. The macro gets all the values from the correct sheet and the calculation is correct. But, when the calculation is done in the active worksheet the cells in all the worksheet that calls the macro is changed with the value calculated in the active worksheet.

How do I make sure that only the cells in the active workseet that calls the macro is changed?

[EDIT]

Example:

I have 2 sheets. In both sheets I have a cell that calls a function: .Value = "=FunctionName()"

When I do calculations in sheet 1, the cell with the call is showing correct result. But the cell in sheet 2 is showing the same result.

Only the cell in sheet 1 should show the result from the function calculated from sheet 1.

Upvotes: 1

Views: 524

Answers (1)

Neha
Neha

Reputation: 50

Say if you want to change in sheet1. Then

Worksheets("Sheet1").Activate
With ActiveWorksheet
Call calculationsmacro     'your macro to calculate the cells
End With

I had kind of similar problem and it was solved by this method. If it works for you then it would be really grateful if you can mark my answer.

Upvotes: 0

Related Questions