I can do that one manually, but I'm not sure how to convert it to a formula:

2d6 (6*6 = 36 outcomes)

Roll - resistance = damage / # of outcomes

2 - 7 = 0 / 1 -- (1/1)

3 - 7 = 0 / 2 -- (1/2, 2/1)

4 - 7 = 0 / 3 -- (1/3, 3/1, 2/2)

5 - 7 = 0 / 4 -- (1/4, 4/1, 2/3, 3/2)

6 - 7 = 0 / 5 -- (1/5, 5/1, 2/4, 4/2, 3/3)

7 - 7 = 0 / 6

8 - 7 = 1 / 5

9 - 7 = 2 / 4

10 - 7 = 3 / 3

11 - 7 = 4 / 2

12 - 7 = 5 / 1

You have to normalize to 36 (# of possible outcomes) on each result so...

All the 0 results come up 1 + 2 + 3 + 4 + 5 + 6 = 21 times

0 damage comes up 21 times = 0***

1 damage comes up 5 times = 5

2 damage comes up 4 times = 8

3 damage comes up 3 times = 9

4 damage comes up 2 times = 8

5 damage comes up 1 time = 5

Sum of the damage outcomes is 5 + 8 + 9 + 8 + 5 = 35

Then divide the final result by the # of outcomes 35/36 ~ 1 damage average.

*** The true sticking point of your formula is going to be how you handle any other static modifiers added to the roll. To get the "real" result you'll need to add the static modifier into the roll and subtract resistance THEN follow the above process.

A quick start of 3d8 would look like this:

3d8 (8*8*8 = 512 outcomes)

3 - 7 = 0 / 1 -- (1/1/1)

4 - 7 = 0 / 3 -- (1/1/2, 1/2/1, 2/1/1)

5 - 7 = 0 / 6 -- (1/1/3, 1/3/1, 3/1/1, 1/2/2, 2/1/2, 2/2/1)

In essence you have to figure out how many times any given result of the dice can occur and multiply the damage done on that result by the number of occurrences. Sum all those results and divide by the total number of possible outcomes. You could then take that result and multiply by your hit % (say .50) to come up with average DPR. This is statistics 101 so maybe a statistics major can give us the formula needed for your application based on input cells such as:

Dice: 3

Range: 8

Static Modifier: +4

Resistance: 7

which amounts to 3d8+4 - 7 (x d y+z)

You'd almost need a script so you can loop to do the stats on each outcome from x to x*y (or 3-24)