Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!
Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “ MacOS X – Your question“, or “ MS Word – Your Tip or Trick“.
Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is most likely no translated for the post!
November 22, 2020 6:15 AM
Hello, i have question about visual basic.
Basicly i have this excel file:
It's like student grade list in every subject.
What i have to do is make a macro which reads it, and if student has more than 3 grades under 4 , it makes macro to do something.
Im not sure what to use in this situation, mayby somebody could give some tips?
November 22, 2020 7:49 AM
I'm not sure a macro is needed.
I'd create a formula to handle this. The COUNTIF function should do the trick, for example:
So this says: count all cells from B2 to G2 where the value is less than 4.
Next you'd like to see those that have more than 3 results that are less than 4, so we can combine that with an IF function to something like this:
=IF( COUNTIF(B3:G3,"<4")>3, "FAIL", "ALL GOOD")
No visual basic needed.
November 22, 2020 8:49 AM
@hans tnx for the reply.
But i need to d it with visual basic :(
Mayby any suggestions with htat?
November 22, 2020 10:16 AM
I'm sorry, but my Visual Basic days are very far behind me ... it would take quite a bit of time for me to figure that out and get familiar with VBA again.
I'm pretty sure though that you can access these functions in VBA as well.
What I would do is probably a for loop in a for loop. In pseudo code something like this:
for each row (each student)
negativeResults = 0 for each column (each of the courses) if column<4 then negativeResults = negativeResults +1 next if negativeResults>3 then "FAIL" else "ALL GOOD" next
November 22, 2020 10:37 AM
Oke, ill try to make it ;)
Thank you very much!