PDA

View Full Version : Looking for help with VBA code please?



Navigator
12-17-2016, 01:57 PM
Hello all,

Sorry for coming here while being a total newbie in terms of VBA codes.
Please let me explain; my 13 yo daughter was recently diagnosed with diabetes and she needs to insert insuline now.
In order to do so, she needs to calculate the carbon hydrates she takes in. For instance; a desert is 17,6 CH per 100 gram and the desert itself is 175 gram. So, for us its easy; 17,6 times 1,75 but not for a 13 yo. A mistake is easy to make with different kinds of food in a meal.

So I made her an excel sheet that does this for her; there seems to be no app that does just this.......weird.
It also calculates (with a "ratio" a "desired value" and a measured bloodsugar value) how much to inject.

This works fine now, but its some work to empty the cells out and reset some of them to their original values. I'm afraid she is to make a mistake like forgetting to empty a cell and inject wrong.
I would also like (if even possible) to write the measured sugar value to another sheet in order to make a graphic. The graphic I already made.

Now I played around with some VBA codes I found on the internet, just to see how this works, but its really, really hard! Also; I can't seem to find the proper codes for the thing I want to do. Making a button for it; wow.......I did it, but more luck than wisdom ;)

So; I'm useless with this.......
On the other hand; I really want this for my girl.
So my question is; would someone please help me out here if its not to much trouble? I would appreciate that very much.

Thanks for reading and sorry for the long story......
Kind regards, Wim.

mikerickson
12-17-2016, 06:41 PM
I would recommend that you contact your doctor and get him to recommend an app.

I'm sure that there are apps out there. Googling brought up many results, including this one.
https://play.google.com/store/apps/details?id=com.cityjams.calculators.insulin&hl=en

The example that you gave, multiplying to get total carbohydrates, would best be handled by the Calculator app on her phone.

Again, I would recommend that you talk to your doctor. There are support groups that are experienced about teaching a teen to manage their disease, the doctor would have the contact information.

You also might want to contact this group:
http://forums.childrenwithdiabetes.com/forumdisplay.php?3-Parents-of-Children-with-Type-1

Aussiebear
12-17-2016, 06:44 PM
Please post your workbook so that we can assist you with this issue. To attach a workbook click on Go Advanced, Scrol down to manage attachments and follow the prompts from there.

Paul_Hossler
12-17-2016, 06:46 PM
It'd be easier to understand if you could attach the workbook AND a description of the calculations you want in terms of things/values/cells on the workbook

Bottom right of the message area is [Go Advanced] that that will open some more icons

One looks like a paperclip, then [Add Files] and [Select Files]

17851

Navigator
12-18-2016, 02:14 AM
Thanks for your replies!

Sorry; attaching the workbook I could have thought of that myself......
Please allow me a little bit of time to translate as it is now Dutch written.

I did ask the doctor for an app, but there seems to be none. I even looked for English written apps, but failed also.
For instance the app Mikerickson pointed out; this one does not calculate the carbon hydrates.
Mine asks how much CH there is per 100 gram and let you fill in how many gram you are taking.
Also a pizza for instance; on the box it says 67 CH in the total of 420 gram; she eats 325 gram.......my excel devices the 67 by 420 and multiplies by 325 to give her the CH she has eaten.
These examples are just what apps don't do.

Just out of bed here, kids waking up; I will be back with the excel in a few hours.
Thanks again for replying.

Navigator
12-18-2016, 02:58 AM
Done!
I wrote what I originally wanted to do with a button in the excel itself.
Calculations are all okay and don't have to be done anymore.

For extra information; I made this excel, and it is used, on an Apple laptop.

SamT
12-18-2016, 12:36 PM
This is still a work in Progress, but I want to share with anybody who wants to help.

I have tried to keep it basic you you can easily understand and maintain or modify it yourself.

The buttons I have added are from the Controls toolbar, not the Forms toolbar

At this time all that happens is that the Meals buttons change to reflect which is clicked.

More functionality will follow soon

Navigator
12-18-2016, 01:09 PM
Wow, that's quick! Thanks for spending time on this SamT.

Unfortunately on opening, it says there is content that Mac osx (or excel 2011?) doesn't support: "active-X".
At this time; I can't open it, sorry.

Edit; pushed the wrong button. I mean I can open it now, but have no functionality.

SamT
12-18-2016, 02:29 PM
Here's version 2. Change Blood Sugar levels and Meal Dates and see what happens
Unfortunately I have no experience with Macs, but when I get it working on Windows, it will be easy for one of our Mac men to port it over.

Navigator
12-18-2016, 03:33 PM
Ah, I understad, thank you!
I will download the file and look at it tomorrow at a windows machine.

mikerickson
12-19-2016, 08:46 AM
The problem with the non-Mac version is the ActiveX controls (use Forms for Mac). I haven't looked at the routine, but Dictionaries are another feature not supported by Mac.