![]() |
Processing code on wrong sheet
I Have a workbook with many sheets. I have code that calculates fields on
all of the sheets and writes the calculations on a "Summary" sheet. My problem is: the calculations are showing up on the last sheet edited (not the summary sheet) Any help is appreciated. Below is the code: Private Sub Workbook_Open() Dim sh As Worksheet, sh1 As Worksheet Dim i As Long Set sh = Worksheets("Summary") i = 0 For Each sh1 In Worksheets If sh.Name < sh1.Name Then i = i + 1 Cells(i, 1).Value = sh1.Range("c36").Value Cells(i, 2).Value = sh1.Range("M34").Value End If Next End Sub |
Processing code on wrong sheet
Hi Jeff
Cells(i, 1).Value = sh1.Range("c36").Value Cells(i, 2).Value = sh1.Range("M34").Value This use the activesheet use this sh.Cells(i, 1).Value = sh1.Range("c36").Value -- Regards Ron de Bruin http://www.rondebruin.nl "Jeff Klein" <Jeff@nospam wrote in message ... I Have a workbook with many sheets. I have code that calculates fields on all of the sheets and writes the calculations on a "Summary" sheet. My problem is: the calculations are showing up on the last sheet edited (not the summary sheet) Any help is appreciated. Below is the code: Private Sub Workbook_Open() Dim sh As Worksheet, sh1 As Worksheet Dim i As Long Set sh = Worksheets("Summary") i = 0 For Each sh1 In Worksheets If sh.Name < sh1.Name Then i = i + 1 Cells(i, 1).Value = sh1.Range("c36").Value Cells(i, 2).Value = sh1.Range("M34").Value End If Next End Sub |
All times are GMT +1. The time now is 02:01 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com