Hey everyone,
I have a Formula code to caluclate the average of a column, ignoring all zeros that works, see below.
Now I want that formula to reference to another closed "Source workbook", not the workbook the makro is in.
I already achieved copying from that "Source workbook" and pasting into my makro workbook
But I want to immediatly apply the formula onto the data in the "Soure workbook" without needing to copy the data.
All help is much appreciated
I have a Formula code to caluclate the average of a column, ignoring all zeros that works, see below.
Now I want that formula to reference to another closed "Source workbook", not the workbook the makro is in.
I already achieved copying from that "Source workbook" and pasting into my makro workbook
But I want to immediatly apply the formula onto the data in the "Soure workbook" without needing to copy the data.
VBA Code:
How can I adress the "Source Workbook" with my Formula?
The Formula Code:
Sub Formula_Active_Row()
Dim r As Long, rr As Long, c As Long
Dim wrng As String
r = 2
rr = Cells(Rows.Count, "D").End(xlUp).Row
wrng = "$D$" & r & ":$D$" & rr
Cells(ActiveCell.Row, 4).Formula = "=AVERAGEIF(" & wrng & ","">0""," & wrng & ")"
End Sub
All help is much appreciated