kelly mort
Well-known Member
- Joined
- Apr 10, 2017
- Messages
- 2,169
- Office Version
- 2016
- Platform
- Windows
I am stacked with this script and I need help to make it happen.
I have 3 sheets that I want to look at a given column for each of them say column B and count for values greater than zero (0) in the said column.
The code I have currently looks like this:
Then when there was no data on sheet 1 it failed to output the sum from the sheet 2.
I could try and add more conditions to the if function but I want to find out if there are better ways of achieving this before I try making the if conditions complicated again.
Thanks in advance.
(Kelly mort)
I have 3 sheets that I want to look at a given column for each of them say column B and count for values greater than zero (0) in the said column.
The code I have currently looks like this:
Code:
If Countif (sheet 1 col B, ">0") >0 And Countif (sheet 2 col B, ">0") >0 And Countif (sheet 3 col B, ">0") >0 Then
MyVar = Sum ( sheet 3 col C)
ElseIf Countif (sheet 1 col B, ">0") >0 And Countif (sheet 2 col B, ">0") >0 And Countif (sheet 3 col B, ">0") =0 Then
MyVar = Sum (sheet 2 col C)
ElseIf Countif (sheet 1 col B, ">0") >0 And Countif (sheet 2 col B, ">0") = 0 And Countif (sheet 3 col B, ">0") = 0 Then
MyVar = Sum (sheet 1 col C)
Else
MyVar = Sum (sheet 1 col C)
End If
Then when there was no data on sheet 1 it failed to output the sum from the sheet 2.
I could try and add more conditions to the if function but I want to find out if there are better ways of achieving this before I try making the if conditions complicated again.
Thanks in advance.
(Kelly mort)