Using Message Boxes And Input Boxes In Excel

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Favorite

    Using Message Boxes And Input Boxes In Excel - Presentation Transcript

    1. Using M essage Boxes and Input Boxes in Excel VBA Microsoft Office Training Excel Training www.bluepecan.co.uk
    2. • If you want to make your macros interactive then one way of doing this is to introduce message boxes and input boxes. These allow you to display messages that require a response or ask the user to enter values before the macro can proceed any further. www.bluepecan.co.uk
    3. S imple g re e ting us ing a me s s ag e bo x • Create an empty workbook and the switch to the Visual Basic Editor (VBE) by clicking Tools > Macro > Visual Basic Editor or by using the shortcut key ALT F11. • If you are using Excel 2007 click on the Developer ribbon and then click on the Visual Basic button. www.bluepecan.co.uk
    4. • Once in the VBE environment you will need to create a module to hold your function. Click Insert > Module In the code window enter the following procedure Sub Greeting() MsgBox "Welcome to my spreadsheet" End Sub • Press F5 to run the macro www.bluepecan.co.uk
    5. Pas s ing a variable to a me s s ag e bo x • In the same procedure as above we will create an input box variable called MyName and declare the variable as a string. We will then concatenate the message “Welcome to my spreadsheet” with the value in the MyName variable. This joins the message in the message box with a value the user enters in an input box. Sub Greeting() Dim MyName As String MyName = InputBox("What's your name?") MsgBox "Hi There " & MyName & "." End Sub • Press F5 to run the macro www.bluepecan.co.uk
    6. Adding mo re info rmatio n to a me s s ag e bo x • Now we are going to use Date, Time and CurDir functions to add more information to our message box. Adjust your code as shown below. Sub Greeting() Dim MyName As String MyName = InputBox("What's your name?") MsgBox "Hi There " & MyName & ". Today's date is " & Date & " and the time is " & Time & ". This file is saved in " & CurDir & "." End Sub www.bluepecan.co.uk
    7. • See this Excel training tutorial on the Blue Pecan website www.bluepecan.co.uk
    SlideShare Zeitgeist 2009

    + Chester TugwellChester Tugwell Nominate

    custom

    780 views, 1 favs, 0 embeds more stats

    If you want to make your macros interactive then on more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 780
      • 780 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 9
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories