I'm trying to write a sub that asks how much oil I made, and then gives me number of barrels needed to hold oil, cost of producing oil, and profit from oil. This is what I have so far, I'm not sure what to do.

Sub Oil()

Dim barrels As Variant
Dim tons As Integer

InputBox "How many tons of oil were produced?"

Barrels = Gallons / 10
cost = 0.38 * Barrels
profit = 0.27 * Barrels

MsgBox "" & Barrels & " barrels needed to hold milk"
MsgBox "Cost of producing oil = " & cost & ""
MsgBox "Profit of producing oil = " & profit & ""
End Sub

sorry, the input box above is supposed to ask how many gallons* of oil were produced

First, the concept of sub programs is to isolate a particular calculation and make a "black box" which returns a "complicated" answer without having to worry about how it is done.

On the other hand, the UI (user-interface) belongs to a separate element of your program which might change due to user feed-back, requirements etc.
It is usually considered good program design to separate the two elements so that changing one does not necessitate the modification of the other.
As you go later into OOP (object oriented programming), the concept will be more clear.

Here you have combined the two design elements together. VBA will allow you to do this, but do bear in mind that in larger programs, this is not a good idea.

In the program, the concept is quite clear: input - calculations - output.

However, You have not defined the variable Gallons, and a value has not been assigned to be before first use. So the sub will not run properly even if it compiles.

You need to store the value of gallons of oil. The syntax (I believe) should be
Gallons=object.InputBox("How many gallons of oil")
where "object" is the object in which the sub resides.

It looks like you're on the right track with your sub for calculating the number of barrels, cost, and profit from producing oil. However, there are a few issues with your code. Let's go through it step by step and make the necessary changes.

First, you'll need to declare the variables `gallons`, `cost`, and `profit` in addition to `barrels` and `tons`.

Next, the `InputBox` function allows you to assign the input value to a variable. In your case, you need to assign the value entered for "How many tons of oil were produced?" to the variable `tons`. To do this, you can use the following code:

```vba
tons = InputBox("How many tons of oil were produced?")
```

Now, let's move on to calculating the number of barrels. In your code, you're using a variable called `Gallons`, which hasn't been declared or assigned a value yet. Instead, you should use the `tons` variable to calculate the number of barrels.

Change the line:

```vba
Barrels = Gallons / 10
```

to:

```vba
barrels = tons / 7.33 ' You can approximate 1 ton of oil to be approximately equal to 7.33 barrels
```

Next, you need to calculate the cost of producing oil and the profit. In your code, you're using the `barrels` variable, but you forgot to declare and assign values to the `cost` and `profit` variables.

Add the following lines after the calculation of `barrels`:

```vba
cost = 0.38 * barrels
profit = 0.27 * barrels
```

Finally, you can display the results using `MsgBox`, as you've done in your code. You can keep those lines unchanged:

```vba
MsgBox "" & barrels & " barrels needed to hold oil"
MsgBox "Cost of producing oil = " & cost & ""
MsgBox "Profit of producing oil = " & profit & ""
```

Putting it all together, your updated code should look like this:

```vba
Sub Oil()
Dim tons As Variant
Dim barrels As Double
Dim cost As Double
Dim profit As Double

tons = InputBox("How many tons of oil were produced?")

barrels = tons / 7.33

cost = 0.38 * barrels
profit = 0.27 * barrels

MsgBox "" & barrels & " barrels needed to hold oil"
MsgBox "Cost of producing oil = " & cost & ""
MsgBox "Profit of producing oil = " & profit & ""
End Sub
```

Now, when you run the `Oil` subroutine, it will prompt you to enter the number of tons of oil produced and then calculate the number of barrels, cost, and profit accordingly.