View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Philosophaie Philosophaie is offline
external usenet poster
 
Posts: 110
Default Passing a range between two subroutines.

Could someone show me where I am going wrong.

[In "ThisWorkbook"]
Private Sub Workbook_Open()
Dim RowsEnd As Double
Dim Target As Range
RowsEnd = Cells(.Rows.Count, "E").End(xlUp).Row

'Not certain if correct
Target = "D27:F" & (RowsEnd + 25)

'Unsure if this will call Worksheet_Change
Worksheet_Change(Target as Range).

End Sub

Private Sub Worksheet_Change(Target as Range)
With Sheets("Sheet4")
For n = 2 To RowsEnd
.Cells(n, 5) = .cell((n - 1), 5) + .cell(n, 6) - .cell(n, 4)
Next n
End With
End Sub