473,396 Members | 2,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Excel macro help

I need help with an excel macro that will take a username (string) in the first column and look at everytime that they either have an P (present), T (tardy), E (Excused), or A (absent) in a second column. They will be given 400 points if they were present every time, but for every T (10 points), A (60 points), E (25 points) will be deducted from their original 400 point score. Any help would be aprreciated, I don't know where to start.
Nov 3 '08 #1
3 1594
Stewart Ross
2,545 Expert Mod 2GB
Hi. This would appear to be a homework question, and much as we would like to help you we cannot do your homework for you. If there is something specific on which you are stuck and need help then please ask for assistance on that - but we simply cannot give you much in the way of help with your homework question when you have put no effort at all into problem solving for yourself.

Please refer to our guidance on Posting Homework Questions in our FAQ reached from the Posting Guidelines at the head of the forum.

MODERATOR
Nov 3 '08 #2
Hi. This would appear to be a homework question, and much as we would like to help you we cannot do your homework for you. If there is something specific on which you are stuck and need help then please ask for assistance on that - but we simply cannot give you much in the way of help with your homework question when you have put no effort at all into problem solving for yourself.

Please refer to our guidance on Posting Homework Questions in our FAQ reached from the Posting Guidelines at the head of the forum.

MODERATOR

This is actually not a homework problem, since I am not in school, but an assistant teacher asks for my help and we are clueless on how to do this, though I took a class in Visual Basic 3 years ago I do not remember it that well and never incoporated it with an office software. So if no help is given I will not cry about it, but I just wanted to help a friend. Also I am not asking for anyone to do this for me, but help point me in the right direction.

But I wanted to add that in excel I'm using a successful fomula and it is . . .
=SUMPRODUCT(COUNTIFS(B:B,G2,E:E,{"A";"E";"T"}),{60 ;25;10})
This then will be subtracted from 400, but I need a macro. Please, any help would be appreciated.
Nov 3 '08 #3
Stewart Ross
2,545 Expert Mod 2GB
I remain uncomfortable with this one - it is possible that a solution to this class problem will undermine the efforts of students who may also be set this problem at some stage. I will provide one possible function which can calculate the demerit total, but otherwise I must leave it to you to do the rest of the work involved in linking this into your worksheet.

Expand|Select|Wrap|Line Numbers
  1. Public Function fTotalDemerits(FirstRow as Long, LastRow as Long, ColumnNo as Long) as Long
  2.  
  3. Dim lngTotal as Long
  4. Dim lngRowCounter as Long
  5. Dim strMarker as String
  6.  
  7. For lngRowCounter = FirstRow to LastRow
  8.    strMarker = activesheet.Cells(lngRowCounter, ColumnNo)
  9.    Select Case strMarker
  10.        Case "A"
  11.          lngTotal = lngTotal + 60
  12.        Case "E"
  13.          lngTotal = lngTotal + 25
  14.        Case "T"
  15.          lngTotal = lngTotal + 10
  16.    End Select
  17. Next lngRowCounter
  18. fTotalDemerits = lngTotal
  19. End Function
The function itself does total the points for cells in the specified column of the activesheet between the specified first and last rows. So, if your markers are in column E between rows 1 and 20 the function's arguments would be 1, 20, 5 (for rows 1 to 20 and column 5 (E)) respectively.

Your task then is to suitably call the function (or write another to do the job), providing the necessary values for the arguments, and place the result of the function back into a cell on the worksheet where you can see it.

-Stewart
Nov 4 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Marc | last post by:
Hi all, I am trying to write an application where I need the ability to open an Excel spreadsheet and do basic read/write, insert rows, and hide/unhide rows. Using win32com I have been able to...
1
by: Steven Stewart | last post by:
I have a user who has been using Excel for a while to keep statistics and print reports. She finds using it cumbersome because of long formulas and a lot of copying and pasting. I have designed...
8
by: Nick M | last post by:
Hello All, Excellent info here Thanks! I am very new to using access in general and I am on a learning curve. I'm trying to import an excel workbook (with worksheets) into an access db via a...
17
by: Mansi | last post by:
I need to do some research on how to use excel automation from c#. Does anyone know of any good books related to this subject? Thanks. Mansi
0
by: Rich Wallace | last post by:
Hello all, Looking for suggestions and tips if possible. I have an application running on a file server that utilizes the FileSystemWatcher to trap when any Excel files are saved by a user. I...
3
by: Mr.Doubt | last post by:
I'm trying to run a Excel macro, which uses SOLVER.XLA Add-In, in VB.NET application. When the macro is executed I get the following error message "Solver: An unexpected internal error occured,...
4
by: michael.pearmain | last post by:
Hi Experts, Looking for a very quick bit on of advice on how to make some python code run. I'm a newbie to both VBA and Python, so i apologise if this is very easy but i'm about to tear my hair...
2
by: Senthil | last post by:
Hi All I need to create an Excel report and create a command button and have to run a macro on the click event that will print all the pages in the Excel workbook. I am able to create the report...
7
by: Holger Fitschen | last post by:
Hi to all, I want to use the Excel solver in a VB.Net project. The macro Sub Makro1Solver() Application.Run "Solver.xla!Auto_Open" SolverReset Worksheets(1).Select...
4
by: mld01s | last post by:
Hi all!! I need help, I have been stuck for a few days on this one. I am trying to open an excel table from a command button in Access. The excel table has an auto_open macro, that is supposed to...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.