Pseudocode
Module 9 of 9
REMINDER: To fully understand Pseudocode, you should have already watched the Pseudocode Video in Canvas and followed along with the Macro Demo file. This practice will build upon that foundation.
Pseudocode in VBA
Pseudocode is plain-language logic written before you write any code. It's not VBA — it has no syntax rules, it won't compile, and Excel can't run it. Its only job is to help you think through the logic of a macro before you start recording or typing. A well-written pseudocode is like an outline for an essay: if the outline is clear, the writing goes much faster and stays on track.
Professor Sanders requires pseudocode as the first step of the macro project for a reason. Students who skip it and go straight to code spend far more time debugging than students who plan first. Pseudocode forces you to identify what programming concepts you need — IF statements, variables, loops — before you're in the middle of writing code and second-guessing yourself.
The pseudocode assignment is graded on communication, not syntax. Ask yourself: if someone who doesn't know VBA read this, would they understand what the macro does? If yes, it's good pseudocode.
Sanders Pseudocode Format
Professor Sanders uses a specific pseudocode format in this course. Keywords are CAPITALIZED. Logic inside IF blocks and loops is indented. Every IF ends with END IF. Every loop starts with a loop instruction and ends with ENDLOOP or NEXT. Use STOP to indicate the macro should exit early — equivalent to Exit Sub in VBA. Variable names and field names are used consistently throughout — not "the student" in one place and "applicant" in another.
Syntax
DEFINE Variables: VariableName1, VariableName2
IF condition THEN
PERFORM action
DISPLAY result
ELSE
DISPLAY alternate message
END IF
SELECT first record
DO UNTIL End_of_File
PERFORM action on current record
MOVE to next record
ENDLOOP
This is the pseudocode structure from the Project Demo — the logic for adding accepted students to the roster:
DEFINE Variables: NewGroup, NumberAccepted, UIN, GPR
IF Applicant Records is Empty THEN
DISPLAY Message "No applicants found"
ELSE
PROMPT user for NewGroup
DISPLAY NewGroup on Valid Values
COPY Applicant Information sheet as backup
SELECT first Applicant record
DO UNTIL End_of_File
IF FinalDecision = Accept THEN
POPULATE variables for UIN, GPR
SELECT Student Information
DISPLAY UIN, GPR, NewGroup, TrackCode
ADD 1 to NumberAccepted
MOVE to next Student row
SELECT Applicant Information
END IF
MOVE to next Applicant
ENDLOOP
REFRESH reports
DISPLAY "X Students Added for Group Y"
END IF
Pre-Pseudocode Questions
Before writing pseudocode, ask yourself four questions about the problem. The answers tell you exactly which programming concepts your macro needs. These questions come directly from Professor Sanders' Macro Handout and are the starting point for every macro you plan.
Syntax
1. Is there any data you need to get from the user? → Yes = InputBox + Variable 2. Does any value change each time you run it? → Yes = Variable 3. Is there anything dependent on a condition? → Yes = IF Statement 4. Is anything repetitive? → Yes = Loop → Do you know how many times? Yes = For Next, No = Do Loop
From Pseudocode to Code
Good pseudocode maps almost directly to VBA structure. A DEFINE line becomes a Dim statement. A PROMPT line becomes an InputBox. A DO UNTIL loop becomes exactly that in code. An IF THEN becomes an If/Then/End If. The logic and the structure are the same — only the syntax changes.
Syntax
Pseudocode → VBA
DEFINE NewGroup As Integer → Dim NewGroup As Integer
PROMPT user for NewGroup → NewGroup = InputBox("Enter group number")
IF records empty THEN → If ActiveCell = "" Then
DISPLAY message → MsgBox "No records found"
STOP → Exit Sub
END IF → End If
DO UNTIL End_of_File → Do Until ActiveCell = ""
MOVE to next record → ActiveCell.Offset(1, 0).Select
ENDLOOP → Loop
Quick Check
1. What is the main purpose of pseudocode?
Pseudocode is planning, not programming. It has no syntax rules and can't run — its only purpose is to think through the logic before you start writing VBA.
2. In Sanders pseudocode format, how should keywords be written?
CAPITALIZED keywords like DEFINE, DISPLAY, POPULATE, DO UNTIL, and ENDLOOP make the structure of the pseudocode visually clear and easy to read.
3. You need a macro that asks for a date, uses it in a calculation, and runs differently depending on whether the result is above or below a threshold. Which concepts do you need?
The date is user input → Variable. The different behavior based on threshold → IF statement. No loop is needed since you're not processing multiple records.
4. Which pseudocode line correctly ends an IF block?
Sanders format uses END IF (two words) to close every IF block. Every IF must have a matching END IF.
5. You're writing pseudocode for a macro that processes every student in a table but you don't know how many students there are. Which loop instruction is correct?
When you don't know the count, use DO UNTIL with an end-of-file condition. FOR loops are for when you know the exact count.
The pseudocode assignment is due before you write any code — that's intentional. If your pseudocode is solid, writing the VBA is mostly just translation. If you're stuck on the code, go back to the pseudocode.
Easy Wins
Read this task description and answer the four pre-pseudocode questions:
"Write a macro that loops through all students in the Applicant Information sheet and counts those whose TAMU GPR is above 3.5. Ask the user what GPR threshold to use instead of hardcoding 3.5. Display the count when done."
Answer each question:
- Is there data to get from the user?
- Does any value change each time you run it?
- Is there anything conditional?
- Is anything repetitive? If yes, do you know how many times?
Work through each question one at a time before looking at the solution.
- Yes — the GPR threshold → InputBox + Variable (Double)
- Yes — the threshold changes each run → Variable
- Yes — only count students above the threshold → IF statement
- Yes — process every student → Loop. Don't know how many → Do Until
Concepts needed: Variable, InputBox, IF statement, Do Until loop.
Using the task from Exercise 1, write the pseudocode using Sanders format.
Start with DEFINE and list the variables you identified in Exercise 1. Note the data type in parentheses after each variable name — this is the Sanders pseudocode convention, not a VBA comment.
DEFINE Variables: GPRThreshold (Double), HighGPRCount (Integer)
Add a PROMPT line for the threshold:
PROMPT user for GPRThreshold
Add the loop structure and the conditional check inside it:
SELECT first student record
DO UNTIL End_of_File
IF TAMU_GPR > GPRThreshold THEN
ADD 1 to HighGPRCount
END IF
MOVE to next student
ENDLOOP
After the loop ends, display the count:
DISPLAY "Students above " GPRThreshold ": " HighGPRCount
DEFINE Variables: GPRThreshold (Double), HighGPRCount (Integer)
PROMPT user for GPRThreshold
SELECT first student record
DO UNTIL End_of_File
IF TAMU_GPR > GPRThreshold THEN
ADD 1 to HighGPRCount
END IF
MOVE to next student
ENDLOOP
DISPLAY "Students above " GPRThreshold ": " HighGPRCount
Practice Problem
Pseudocode the Guard Check Macro
Write pseudocode for the guard check macro from Module 2 using Sanders format. The macro should:
- Check if the Applicant Information sheet has records
- If empty: display a message and stop
- If not empty: ask for a group number, then display a ready message
Requirements:
- Use DEFINE for any variables
- Use CAPITALS for all keywords
- Indent logic inside IF blocks
- End every IF with END IF
Expected pseudocode:
DEFINE Variables: NewGroup (Integer)
SELECT Applicant Information sheet
IF A2 is empty THEN
DISPLAY "No applicants found"
STOP
ELSE
PROMPT user for NewGroup
DISPLAY "Group " NewGroup " is ready to process"
END IF
Challenge
Pseudocode the Full Aggie Advisors Macro
No hints. No steps. This is exam level.
Write complete pseudocode for the full AddNewStudents macro from the Aggie Advisors project. Your pseudocode must cover all of the following using Sanders format:
- Variable definitions
- Guard check for empty applicant list
- User prompt for group number
- Copy Applicant Information as backup
- The main processing loop — reading variables, adding to Student Information, counting accepted students
- Refresh reports
- Completion message
Your pseudocode should be detailed enough that someone who doesn't know VBA could understand exactly what the macro does, step by step.
Refer to the Aggie Advisors practice project for the full macro context if needed.
See the full Aggie Advisors project →You've covered all nine modules — macro foundations, programming concepts, variables, loops, calculations, references, filters, debugging, and pseudocode. You're ready to tackle your project. Use the Aggie Advisors practice project as your dry run, and refer back to any module when you need a refresher.