Michele317
New Member
- Joined
- Apr 29, 2024
- Messages
- 28
- Office Version
- 365
- Platform
- Windows
Hello,
I'm trying to find a way to operate only with the previous sheet.
I explain better what I mean with an example.
I have 3 sheets: A, B e C.
In sheet A I have a value in a cell, for example 1.
In sheet B I have 2.
In sheet C I have 3.
What I want to be able to do is to have a cell in sheet B that, for example, sum the value in the same sheet (sheet B) with the value in the previous sheet (sheet A). So, in sheet B i would have in a cell the value 1+2=3
In sheet C I want to do the same. So, in a cell in sheet C I would have 3+2=5
I have tried to play with the .Count() function but I think it's a little to vulnerable and easy to break. This because, if I create a sheet and then i delete it, the whole macro broke.
I post down what I have done and that has the problem I just explained:
Thank you all in advance
I'm trying to find a way to operate only with the previous sheet.
I explain better what I mean with an example.
I have 3 sheets: A, B e C.
In sheet A I have a value in a cell, for example 1.
In sheet B I have 2.
In sheet C I have 3.
What I want to be able to do is to have a cell in sheet B that, for example, sum the value in the same sheet (sheet B) with the value in the previous sheet (sheet A). So, in sheet B i would have in a cell the value 1+2=3
In sheet C I want to do the same. So, in a cell in sheet C I would have 3+2=5
I have tried to play with the .Count() function but I think it's a little to vulnerable and easy to break. This because, if I create a sheet and then i delete it, the whole macro broke.
I post down what I have done and that has the problem I just explained:
VBA Code:
Sub Calcolo_tot()
Dim i As Integer
i = Worksheets.Count - 1
Sheets(Worksheets.Count).Range("J35").Value = Sheets(Worksheets.Count).Range("J34").Value + Worksheets(i).Range("J35")
End Sub
Thank you all in advance