|
Business Solutions: Excel-Build Your Own Functions By James D. Duncan November 2005
Excel has built- in functions of all sorts. Some are easy to use and some are more complicated. The function “Now,” for instance, will give you the time and date it is at this instant. This is accomplished by entering “=Now()” into a cell.
When you press Enter, the results will give you the current date and time.
If you want to make a function of your own, this will show you how. Click on Tools, select macro and select Visual Basic Editor. The following screen appears.
You will be in the sheet section and you want to put this in a Module. Select Insert, select Module and enter the following code.
Function User() ' Returns the name of the current user User = Application.UserName End Function
This is how the screen will look after you are finished.
Now, back on the worksheet enter “=User()” and press Enter. And the current user appears in that cell.
Now, anywhere you want the user name, you can enter that code. There are many examples in the Excel help and many more on the Web. Any special procedure or function that you need can be written in the Visual Basic editor.
As always, practice is what gives us our skills. Read, research and play with the code. You will expand your skills and your patience too! Go help an organization and you will get much more out of the experience than the time and effort you expended. Fran and I spent our last Saturday morning doing just that. And we are not finished by a long shot. So, be one of the precious people who help in the community.
James is a member of the CCOKC and an expert in Access and Excel. Click here to reach James |