Dim a, b, c, ihigh, ilow, simp1, fa, fb, simp2, adb, simpson, As Double
Dim n as Integer
' Validate user input
a = Range("aval").Value
b = Range("bval").Value
c = Range("cval").Value
ihigh = Range("inthigh").Value
ilow = Range("intlow").Value
n = Range("nval").Value
If Len(a) = 0 Or Len(b) = 0 Or Len(c) = 0 Or Len(ihigh) = 0 Or Len(ilow) = 0 Or Len(n) = 0 Then
' Alert user that entries have not been filled out
MsgBox "You need to enter input values before continuing.", vbExclamation, "Warning Message"
simp1 = (b-a)/6
fa = (a * aval^2) + (b * aval) + c
adb = (a + b)/2
simp2 = 4 * ((a * adb^2) + (b * adb) + c)
fb = (a * bval^2) + (b * bval) + c
' Calculate Simpson value
simpson = simp1*(fa + simp2 + fb)
I got that formula from here:
You'll need to output the simpson value somewhere on the spreadsheet or a message box. Let me know if you need help with that. I put this code together quickly this morning. i'm not sure how much VB/Excel knowledge you have, so if you do have questions, by all means, ask.
I assume you are doing this in VBA to hide it from others, but it's very easy to do in Excel. I put in a warning message to validate user input, and made it an Exclamation warning to catch the user's eye if they make a mistake on entry points.