Scaling Up: Handling N x N Systems
In Part 4, we looked at the basic user interface. But engineering problems aren't fixed at 3x3. A truss analysis might need 10 equations; a thermal grid might need 100.
A professional Excel tool must be Dynamic. It should automatically resize the input table based on the user's needs, clearing old data and preparing fresh cells for input.
1. User Input for Dimensions
The process starts with a simple input request. In our design, clicking "Main Menu" > "New Equations" triggers a VBA InputBox or UserForm asking for the number of variables (N).
For this example, let's input 10 to simulate a larger structural problem.
2. Managing Data Integrity
When resizing a matrix, you must decide what to do with old data. Our reference design includes a safety check: "Existing equations will be deleted." This prevents users from mixing data from a 3x3 problem with a new 10x10 grid.
3. Automating the Resize (VBA Logic)
Behind the scenes, your VBA code needs to do the heavy lifting.
How it works conceptually:
- Clear Range: The code identifies the old range (e.g., B3:D5) and runs
.ClearContents. - Redefine Range: Based on the input N=10, the code calculates the new range (B3:K12).
- Formatting: It applies borders and background colors to the new range so the user knows exactly where to type.
4. Solving the Large System
Once the data is entered, the Gauss Elimination algorithm we wrote in Part 1 handles the 10x10 matrix just as easily as the 3x3.
Clicking "Solve" populates the 10x1 result vector instantly.
5. Verification: The MMULT Function
Trust but verify. A good engineer always checks the results. In Excel, you can use the built-in function =MMULT() to multiply your original [A] matrix by the calculated {X} vector.
If the result matches your original {B} vector, the solution is correct.
MMULT to multiply [A]*{X} confirms the solution matches {B}.Conclusion
By combining robust math (Gauss Elimination) with smart VBA (Dynamic Ranges), you can build powerful engineering tools that rival commercial software.
In the final post, we will share a video demonstration of this tool in action.
Continue to Part 6:
Solving System of Equations using Gauss Elimination Method (Part 6: Video Demo)

Comments