code

Y

Yossy

The following code calculate on all sheets in a workbook named _Trial. I want
to do another calculation on other sheets named _Code. How do I add that to
the code.

For other sheets named _Code, I want to add cell g36 to cell g23.

Sub T_Balances()
Dim ws As Worksheet
Application.ScreenUpdating = False
For Each ws In Worksheets
If InStr(1, ws.Name, "_Balances") Then
With ws
..Range("g35").Value = .Range("g40").Value
With .Range("g23")
formStr = .Formula
..Formula = formStr & "+" & ws.Range("g36").Value
End With
With .Range("g30")
formStr = .Formula
..Formula = formStr & "+" & ws.Range("g57").Value
End with
End With
End If

Help me in putting this code in one, so that it does calculation on multiple
sheets while putting into consideration different names. Thanks
 
Y

Yossy

The following code calculate on all sheets in a workbook named _Balances. I
want to do another calculation on other sheets named _Code. How do I add that
to the code.

For other sheets named _Code, I want to add cell g36 to cell g23.

Sub T_Balances()
Dim ws As Worksheet
Application.ScreenUpdating = False
For Each ws In Worksheets
If InStr(1, ws.Name, "_Balances") Then
With ws
..Range("g35").Value = .Range("g40").Value
With .Range("g23")
formStr = .Formula
..Formula = formStr & "+" & ws.Range("g36").Value
End With
With .Range("g30")
formStr = .Formula
..Formula = formStr & "+" & ws.Range("g57").Value
End with
End With
End If

Help me in putting this code in one, so that it does calculation on multiple
sheets while putting into consideration different names. Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top