I'll make this clear and simple, since I'm on a deadline here. Doing some reports for my section, and I came to a part where I could really use an interpolation in Excel.
Now, I've never had any practice with its functions, or VBA in general. So, is there a place where I could, or do anyone of you guys know some, ... where I could pick up a simple spline interpolation along with a tutorial of "how to make it work" (literally, I have no idea - I use Excel on a one-handful-of-times-on-an-annual-basis)?
I just need something that will put up a spline (or something similar) on an x and y column of values, and give me the interpolated result given values of X.
p.s. I know however of trendlines, but they're no use for me in this case. I cannot get the coefficients "programmatically" ...
I'd really appreciate some pragmatical help.
http://www.ozgrid.com/Excel/excel-interpolate-cubic-curve-fit.htm
XlXtrFun.xll is what I use to get splines in Excel.
This is a free add-in for Excel that adds spline and linear interpolation workbook functions:
http://www.srs1software.com/SRS1CubicSplineForExcel.aspx
Related
Background: Novice user and VBA programmer - be gentle, please.
Scenario:
Using a Visio (2010) straight line connector;
Currently 1-D Endpoints.BeginX is as follows:
=PAR(PNT(Milestone.40!Connections.X1,Milestone.40!Connections.Y1))
What I have:
A data field in the same shape called BeginItem that contains the Visio ID (e.g. 87) of Milestone.40! above.
What I need to know:
If possible, how to change the formula in 1-D Endpoints.BeginX to something like:
=PAR(PNT(BeginItemValue!Connections.X1,BeginItemValue!Connections.Y1))
and if not possible, is there an alternative way of doing this?
Thanks!
Thanks for helping all. A combination of all advice led me to an alternative solution.
Instead of trying to refer to the field in the Shapesheet that does contain the BeginItemValue, I built the entire string (in VBA) by concatenating the parts and then updated the BeginX value with it.
shpObj.Cells("BeginX").Formula = "=PAR(PNT(" & BeginItemValue & "!Connections.X1," & BeginItemValue & "!Connections.Y1))"
That worked well, although I'm sure there are easier ways of doing it.
I am a complete novice when it comes to vba but I want to help a friend out, so I could use some guidance with a problem. I figure something like this is on the internet already, but I cannot find it, so if you have a suggestion as to where I could look, I would appreciate it.
I have a vba project with 19 modules, which compiles with no errors or warnings. The program calculates economic rate of return, given certain events. All the results come out as they should, apart from a single one. I am all but certain, that there is a mathematical flaw with this particular input, but I cannot locate it. This leads me to my question:
How can I obtain output from a (mathematical) function defined in vba? Preferably for discrete values of time, but at this point any help will do.
Simply call it. You can do it from a cell in a spreadsheet:
Assuming the function is called myMathematicalFunction and takes one parameter:
A1:
=myMathematicalFunction(B1)
B1:
<input value to test>
Okay, I am a Javascript programmer and VBA is driving me insane - I know nothing about it and it is like pulling teeth to find simple documentation on the simplest thing.
I'm literally trying to run a little script to auto-format a document, partly based in content.
I want to grab the third line of document, or first 100 characters, I really don't care, and run the equivalent of String().indexOf('foobar') on it, to check if that part of the document contains a string.
I cannot for the life of me find how to:
a. Load text selection into a variable.
b. Run a sane semblance to indexOf.
Can someone please help? And maybe point me to a sane VBA documentation that is not Micrsoft?
a. Load text selection into a variable.
Identify a range (Word.Range) you want and get the Text property of that range.
For instance,
dim s as string
s = ThisDocument.Paragraphs(3).Range.Text
b. Run a sane semblance to indexOf.
Is InStr no good?
msgbox InStr(s, "foobar")
I am writing a macro in VBA for excel in which I would like to change the transparency of the lines connecting markers in a series but leave the transparency of the markers in the series the same.
To specify: the chart is a scatter plot. I would like the markers for a series to be opaque/zero transparency and for the lines in the series to be 75% transparent.
I have adjsuted the transparency of the lines by using
myseries.format.line.transparency = 0.75
but this changes the marker transparency as well.
does anyone know of a way I can change the transparency of the two separately? I imagine there is a member/property to do what I want, but I cannot find it.
thanks in advance for any help!
This answer isn't going to make you very happy.
I've looked into this before and the information i've gotten is that this simply isn't a parameter that you can specify through VBA. It looks like you can access marker style, size, background color and foreground color, and that's about it.
Maybe MS didn't think anyone would ever want to mess with that.
One thing you could try is applying a custom chart format, but if you have variable numbers and/or orders of series then that may not work.
mychart.ApplyChartTemplate ("filepath\filename.crtx")
Something like that, where mychart is already set equal to the chart you want to format.
Again, maybe not of any use to you, best i could think of.
You guys didn't dig hard enough.
SeriesCollection(i).Format.Line.Transparency
will work if the SeriesObject is in a certain state. The original 'automatic' line style state prevents this vba from doing anything at first, but if you simply precede it by setting certain other properties on the line format first, then the transparency will take. The following worked for me:
For Each obj In myChart.SeriesCollection
obj.Format.Line.DashStyle = 1
obj.Format.Line.Transparency = 0.65
Next obj
DashStyle = 1 sets the line style to 'Solid' (as opposed to dashed, dotted, etc.) and has the side effect of freeing up the series format to have the transparency set. I don't know for sure why it works, but it does.
Sorry, my mistake. I read the question slightly wrong.
I find that if I start the line with no markers, then turning transparency separately doesn't turn the markers on and off.
Try this:
activechart.SeriesCollection(1).format.fill.transparency=0.5
I'm trying to use either PERCENTILE.EXC, PERCENTILE.INC or PERCENTILE.
Looking at FormulaParserManager.GetImplementedFunctionNames() these are not implemented functions.
I wondered if I could set the formula and leave it to Excel to calculate. So far I've not got this to work and I get a #NAME? and "The formula contains unrecognized text". Merely clicking in the formula bar causes the formula to be calculated correctly.
Inspecting the internals of the Excel file I am creating (via EPPlus):
_xludf.PERCENTILE.EXC(B14:B113,0.95)
whereas in Excel I get:
_xlfn.PERCENTILE.EXC(A14:A113,0.95)
I think this is user defined function vs function. I've tried prefixing "_xlfn." to my formula string.
This is as far as I've got I think I either need to roll my own percentile calculation in code or manipulate the xml in the Excel file maybe.
Any help appreciated.
Doh! I spend all afternoon stuck, post a question here and then immediately suss the answer...
Anyway in case anyone is interested:
var row95 = percentile95RowLookup[profileKey];
var percentileRange = sheet.Cells[row, i, row+ profileCollection.Profiles.Count-1, i];
sheet.Cells[row95, i].Formula = $"_xlfn.PERCENTILE.INC({percentileRange.Address},0.95)";
With the important proviso that workbook.CalcMode is not Manual.