ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   code (https://www.excelbanter.com/excel-programming/422426-code.html)

Yossy

code
 
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

Yossy

code Help Please
 
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

"Yossy" wrote:

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



All times are GMT +1. The time now is 03:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com