Page 1 of 1
Forum

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 no translation for that post!




Visual basic
 
Share:
Notifications
Clear all

Visual basic

5 Posts
2 Users
0 Likes
1,430 Views
(@rdiizz)
Active Member
Joined: 3 years ago
Posts: 9
Topic starter  

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?

 

 


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 10 years ago
Posts: 2554
 

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:

=COUNTIF(B2:G2,"<4")

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.


   
ReplyQuote
(@rdiizz)
Active Member
Joined: 3 years ago
Posts: 9
Topic starter  

@hans tnx for the reply.

But i need to d it with visual basic :(

Mayby any suggestions with htat?


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 10 years ago
Posts: 2554
 

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

 


   
ReplyQuote
(@rdiizz)
Active Member
Joined: 3 years ago
Posts: 9
Topic starter  

Oke, ill try to make it ;)

Thank you very much!


   
ReplyQuote


Like what you see and you'd like to help out? 

The best way to help is of course by assisting others with their questions here in the forum, but you can also help us out in other ways:

- Do your shopping at Amazon, it will not cost you anything extra but may generate a small commission for us,
- send a cup of coffee through PayPal ($5, $10, $20, or custom amount),
- become a Patreon,
- donate BitCoin (BTC), or BitCoinCash (BCH).

Share: