To solve this optimization problem, we first need to define the decision variables, objective function, and constraints based on the given information.

Let's denote:
- \(x\) as the number of meatball sandwiches made.
- \(y\) as the number of ham sandwiches made.

The objective is to maximize profit. The profit per meatball sandwich is $3, and the profit per ham sandwich is $3.50. Therefore, the total profit can be represented by the equation:
\[ \text{Total Profit} = 3x + 3.5y \]

Now, let's consider the constraints based on the available ingredients:
1. **Meat Constraint**: Each meatball sandwich requires 25 grams of meat, and each ham sandwich requires 30 grams of meat. The store has 4000 grams of meat available.
\[ 25x + 30y \leq 4000 \]

2. **Cheese Constraint**: Each meatball sandwich requires 10 grams of cheese, and each ham sandwich requires 25 grams of cheese. The store has 5000 grams of cheese available.
\[ 10x + 25y \leq 5000 \]

3. **Sauce Constraint**: Each meatball sandwich requires 50 grams of sauce, and each ham sandwich requires 20 grams of sauce. The store has 5200 grams of sauce available.
\[ 50x + 20y \leq 5200 \]

4. **Non-Negativity Constraints**: The number of sandwiches cannot be negative.
\[ x \geq 0 \]
\[ y \geq 0 \]

Given these constraints and the objective function, we can now write the Gurobi code in Python to solve this linear programming problem.

```python
from gurobipy import *

# Create a new model
m = Model("Sandwich_Optimization")

# Define the decision variables
x = m.addVar(name="meatball_sandwiches", vtype=GRB.CONTINUOUS, lb=0)
y = m.addVar(name="ham_sandwiches", vtype=GRB.CONTINUOUS, lb=0)

# Set the objective function
m.setObjective(3*x + 3.5*y, GRB.MAXIMIZE)

# Add constraints
m.addConstr(25*x + 30*y <= 4000, name="meat_constraint")
m.addConstr(10*x + 25*y <= 5000, name="cheese_constraint")
m.addConstr(50*x + 20*y <= 5200, name="sauce_constraint")

# Optimize the model
m.optimize()

# Print the results
if m.status == GRB.OPTIMAL:
    print(f"Optimal solution: {x.varName} = {x.x}, {y.varName} = {y.x}")
    print(f"Total Profit: ${3*x.x + 3.5*y.x:.2f}")
else:
    print("No optimal solution found")
```