- For individual users
- Instant access to solutions
- Ask your tech questions
- Start your 30-day Free Trial
Main Topics
Browse All TopicsHi,
I need the countif function as a macro in which one macro calculates the number of 5s, 4s, 3s, 2s, 1s and total count of one coloumn. (coloumn C)
Sheet name = Score summary
I want something like:
If cellvalue <> then
Counttotal = counttotal +1;
If cellvalue = 1 then
Count1 = count1 +1
End If
If cellvalue = 2 then
Count2 = count2 +1
End If
If cellvalue = 4 then
Count4 = count4 +1
End If
If cellvalue = 5 then
Count5 = count5 +1
End If
End If
Now i want to tell macro to put counter results in adjacent cells. (in a table) on Score Summary sheet.
Count1
Count2
Count4
Count5
Counttotal
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: byundtPosted on 2009-03-28 at 18:11:54ID: 24010978
voccoe,
The easiest way of doing this is with the COUNTIF formula itself. If put a stop in the code at statement 7, you can see how the formula is doing the work.
If you really need to loop through the cells, could you give a bit of explanation as to why? If this is a homework assignment, I don't want to cause you any difficulty with the prof.
To install a sub in a regular module sheet:
1) ALT + F11 to open the VBA Editor
2) Use the Insert...Module menu item to create a blank module sheet
3) Paste the suggested code in this module sheet
4) ALT + F11 to return to the spreadsheet
To run a sub or macro:
5) ALT + F8 to open the macro window
6) Select the macro
7) Click the "Run" button
Optional steps to assign a shortcut key to your macro:
8) Repeat steps 5 & 6, then press the "Options" button
9) Enter the character you want to use (Shift + character will have fewer conflicts with existing shortcuts)
10) Enter some descriptive text telling what the macro does in the "Description" field
11) Click the "OK" button
If the above procedure doesn't work, then you need to change your macro security setting. To do so, open the Tools...Macro...Security menu item. Choose Medium, then click OK.
Brad
Select allOpen in new window