View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Anders S[_2_] Anders S[_2_] is offline
external usenet poster
 
Posts: 57
Default Doing a calculation, then looping for several of the same calc

jdfisher1,

I don't understand why you have to involve Sheet1 or use a macro at all.
On Sheet3 you can reference Sheet2 like
=Sheet2!A1
in cell A1, then fill down to A10 and do the calculations in columns B and C on
Sheet3.

However, if you must use a macro, you can try this:

'*****
Option Explicit

Sub test7948()
Dim srcSheet As Worksheet
Dim calcSheet As Worksheet
Dim destSheet As Worksheet
Dim srcCell As Range
Dim rowNum As Integer

Set srcSheet = Sheets("Sheet2")
Set calcSheet = Sheets("Sheet1")
Set destSheet = Sheets("Sheet3")
rowNum = 0

For Each srcCell In srcSheet.Range("A1:A10")
calcSheet.Range("B4").Value = srcCell
destSheet.Range("A1:C1").Offset(rowNum, 0) _
.Value = calcSheet.Range("B4:D4").Value
rowNum = rowNum + 1
Next
End Sub
'*****

HTH,
Anders Silven

"jdfisher1 " skrev i meddelandet
...
Yes. Sheet 1 performs a calculation (separate from the macro).
Basically, sheet 1 is an accounting sheet that has pluses and minuses
based on the input from A1 in Sheet2. The result from Sheet1 is found
in fields B4:D:4. The result (B4:D:4) should be pasted in sheet 3.
Does that make more sense?


---
Message posted from http://www.ExcelForum.com/