byronwall / bUTL

Excel add-in with helpers for charting, formatting, and general pain points
http://byroni.us/bUTL
MIT License
16 stars 3 forks source link

Error Handling is lacking for some routines and functions #31

Closed RaymondWise closed 9 years ago

RaymondWise commented 9 years ago
Module Action
Chart_Format.VBA sub Chart_CreateDataLabels()
Chart_Format.VBA sub ChartCreateXYGrid()
Chart_Processing.VBA sub CreateMultipleTimeSeries()
Chart_Series.VBA sub ChartMergeSeries()
Usability.VBA function GetRow()
Usability.VBA sub ExportFilesFromFolder()
Usability.VBA sub FillValueDown()
Usability.VBA sub SeriesSplit()
byronwall commented 9 years ago

I will add error handling to these. It is definitely needed. I have been using that SeriesSplit lately and have been getting annoyed when I hit cancel and get a runtime error.

The GetRow function probably needs to be integrated into the place where it is used. I think it is just used for the Copy as CSV feature. I was being lazy when I did that one and just needed a quick solution. That is a decent feature to have but it needs some improvement. I'll take a look at it and create a new issue.

I will add error handlers to the other ones. Most of them are using InputBoxes which are very likely to have an error at some point.

byronwall commented 9 years ago

All of the Subs mentioned above have error handlers added or the code changed to not throw errors. For the Chart related ones, I replaced the Selection with the Function Chart_GetObjectsFromObject. This is a poorly named function that goes through whatever object (usually Selection) and returns a Collection of ChartObjects if there are any contained in the Selection. This makes error handling easy since the collection will be empty if nothing was there and the For Each will simply skip over the empty Collection.

For GetRows, I just deleted it and replaced the one usage with a double Tranpsose. It works just as well.

For 2 of the Usability ones, I replaced Selection with a Function GetInputOrSelection which is the new bit covered by #14 . Error handling can be done inside that Function with a new check that the return of the Function Is Nothing.