ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

Handy Excel Restaurant Tip Calculator (Free Software)

Updated on June 23, 2012

I’m sure there are apps for this, but if you do not have one this little program might be useful. More so if you, like I, are not adept at doing math in your head. Maybe not after a few drinks either. You will need Microsoft Excel on your phone or tablet. We will go through how to install the program here. It will involve copying and pasting a few lines of code into Excel. Here we go: Open up Excel, save the new file as “tip.xlsm”. In newer versions of Windows, you will save as type “Excel Macro-Enabled Workbook”. All this will be is a blank spreadsheet with embedded code to calculate the tip. You will need access to the Developers tab in Excel. To make it visible in the new spreadsheet do as follows:

1. File --> Options (click)

2. Customize Ribbon (click)

3. Check the “Developer” box and click “OK” at bottom. 4. You will now see “Developer” tab. Click it.

5. Section dealing with macros and VBA (Visual Basic) is now visible.

We will now create a macro, into which we will later paste some code. Over on the left, find the tab “Record Macro” and click it. A box pops up. It will have been given a default name, just leave it. There will also be a shortcut key entry, make it “ctrl a”. Click OK. Do not press any keys, or you will actually start recording keystrokes in the macro. Rather, immediately click the “stop recording” tab, located in same place where “Record Macro” was. We have created a blank routine into which we will now place some code. Almost done. Click on “Macros” and you will see the blank macro we just created. Click “Edit”. The macro will open up in a window, see picture in the diagram. Place the blinking cursor as shown. In order to do so, you will have to down arrow key until the cursor sits next to "End Sub". Hit Enter key 5 times to move "End Sub" down. Up arrow key 3 times to put the cursor between "End Sub" and lines above it. Now copy and paste in this code:

Dim bill As Single, percent As Single, tip As Single, tipstr As String

On Error GoTo BadCalculation

bill = InputBox("Enter the dinner bill. For example, $60.50 will be 60.50.")

percent = InputBox("What % tip do you want to leave? For example, 20% will be 20.")

tip = percent / 100 * bill

tipstr = Str(tip)

MsgBox "tip = $" & tipstr

Exit Sub

BadCalculation:

MsgBox "There was a problem when performing the calculation. Run it again"

Close the program box and re-save the workbook. Hit “ctrl a” and the tip calculator will run. That’s it, hope it works well for you.

Comments

    0 of 8192 characters used
    Post Comment

    No comments yet.

    Click to Rate This Article