hamdyeleraky
New Member
- Joined
- Dec 31, 2015
- Messages
- 3
Hello ,
I am in urgent need of help. I am quite new to VBA so it might be something obvious but appreciate all comments
There is a dynamic range of data in "Mastersheet" in Column "I" that i would like to get their average and return it back to another sheet "Charts" in a specific cell (B1) but i would like to only average data that fulfill one OR two string conditions (Mastersheet in Column D and E)
It return an error that i am unable to debug (only that the issue is in set s1...) and i have tried normal AverageIFS and it return average for the conditions having an AND relation not OR
Please help
Thanks!
[Sub Avg()Dim x As Integer
Dim s1, s2
Dim lrow As Long
Set s1 = Worksheets("Charts")
Set s2 = Worksheets("mastersheet")
lrow = s2.Cells(Rows.Count, "C").End(xlUp).Row
For x = 2 To lrow
If s2.Range("D" & x) = "GoGreen" Or s2.Range("E" & x) = "GoGreen" Then
s1.B8.Formula = "=Average(s2.I1:I10)"
End If
Next x
End Sub]
I am in urgent need of help. I am quite new to VBA so it might be something obvious but appreciate all comments
There is a dynamic range of data in "Mastersheet" in Column "I" that i would like to get their average and return it back to another sheet "Charts" in a specific cell (B1) but i would like to only average data that fulfill one OR two string conditions (Mastersheet in Column D and E)
It return an error that i am unable to debug (only that the issue is in set s1...) and i have tried normal AverageIFS and it return average for the conditions having an AND relation not OR
Please help
Thanks!
[Sub Avg()Dim x As Integer
Dim s1, s2
Dim lrow As Long
Set s1 = Worksheets("Charts")
Set s2 = Worksheets("mastersheet")
lrow = s2.Cells(Rows.Count, "C").End(xlUp).Row
For x = 2 To lrow
If s2.Range("D" & x) = "GoGreen" Or s2.Range("E" & x) = "GoGreen" Then
s1.B8.Formula = "=Average(s2.I1:I10)"
End If
Next x
End Sub]