Lecture-14a(inputbox-macros)

Lecture-14a(inputbox-macros) - cells of a spreadsheet, you...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
Running VBA Codes Lecture - 14
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Running a Macro Tools Macro Select the cell where you want to return the value
Background image of page 2
Alternatively…. . Click on Run Icon Notice that if you have the Cursor here and then press on the Run Icon, the macro is automatically executed and the value is returned to the spreadsheet If you put the cursor here and then press the Run Icon, you are asked to select the Macro that you want to run from a list
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Remark Error because we have defined our procedure to be a Sub not a Function. Functions can be run by specifying a name and a argument list
Background image of page 4
Using Forms to Run the Macro Select the location where you would like a run button to appear
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Creating a form for running macro Draw the button using the mouse Assign the name of the macro that you want to run to the button Edit the name to whatever you like Click on the button and the macro should run
Background image of page 6
Using an Input Box to Obtain Data Instead of supplying the input data as part of an argument list or reading in the values directly from the
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 8
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 10
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: cells of a spreadsheet, you can use an INPUT BOX to query the user for information Syntax P = InputBox(Please enter the value for Pressure (atm) Note The default syntax for the InputBox command assigns a string constant for P. Cannot perform math calculations with a string constant. Hence: Revised Syntax P = Val(InputBox(Please enter the value for Pressure (atm)) Converts string to a number An Example Do you remember how to set up this Run button? Using Message Box to Display Result You can change the program to display the results of a calculation in a Form (as well as write out the result into a cell in the spreadsheeet) Syntax MsgBox Vol Returns the result of the calculation for Vol in a Message Box Message Box (Contd) A better way to use the Message Box is: The & symbol concatenates together the label The Calculated Ideal Volume is and the calculated value Vol...
View Full Document

This note was uploaded on 04/27/2008 for the course PGE 310f taught by Professor Srinivasan during the Spring '08 term at University of Texas at Austin.

Page1 / 10

Lecture-14a(inputbox-macros) - cells of a spreadsheet, you...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online