ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cell Value in one sheet using SUM formula in another (https://www.excelbanter.com/excel-programming/357812-cell-value-one-sheet-using-sum-formula-another.html)

Mike[_92_]

Cell Value in one sheet using SUM formula in another
 
Am using code below to loop through worksheets in workbook. Objective
is to place value in cell where that value is determined by the sum of
a range of cells on another sheet.

My current code is:

For Each sh In ThisWorkbook.Worksheets
If sh.Name "000" Then
Last = LastRow(DestSh)
DestSh.Cells(Last + 1, "A").Value = sh.Name
DestSh.Cells(Last + 1, "C").Value = _
sh.Range("E46").Value + sh.Range("F46").Value + sh.Range("G46").Value
DestSh.Cells(Last + 1, "D").Value = _
sh.Range("H46").Value + sh.Range("F46").Value
End If
Next

Instead of:
DestSh.Cells(Last + 1, "C").Value = sh.Range("E46").Value + _
sh.Range("F46").Value + sh.Range("G46").Value

I would like DestSh.Cells(Last + 1, "C").Value = SUM("E46:G46") on sh.

Thanks In Advance...

Mike


Tom Ogilvy

Cell Value in one sheet using SUM formula in another
 
DestSh.Cells(Last + 1, "C").Value = Application.SUM(sh.Range("E46:G46"))

--
Regards,
Tom Ogilvy


"Mike" wrote in message
ups.com...
Am using code below to loop through worksheets in workbook. Objective
is to place value in cell where that value is determined by the sum of
a range of cells on another sheet.

My current code is:

For Each sh In ThisWorkbook.Worksheets
If sh.Name "000" Then
Last = LastRow(DestSh)
DestSh.Cells(Last + 1, "A").Value = sh.Name
DestSh.Cells(Last + 1, "C").Value = _
sh.Range("E46").Value + sh.Range("F46").Value + sh.Range("G46").Value
DestSh.Cells(Last + 1, "D").Value = _
sh.Range("H46").Value + sh.Range("F46").Value
End If
Next

Instead of:
DestSh.Cells(Last + 1, "C").Value = sh.Range("E46").Value + _
sh.Range("F46").Value + sh.Range("G46").Value

I would like DestSh.Cells(Last + 1, "C").Value = SUM("E46:G46") on sh.

Thanks In Advance...

Mike




Mike[_92_]

Cell Value in one sheet using SUM formula in another
 
Tom....many thanks. Wish I could meet you someday...kind regards



All times are GMT +1. The time now is 04:26 PM.

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