Databases Reference
In-Depth Information
3.
In the CDSales module sheet, type the following code:
Public SalesPrice As Integer
Public UnitsSold As Integer
Public CostPerUnit As Integer
Private Markup As Long
Sub CDSales()
Dim X as String
SalesPrice = 12
UnitsSold = 1000
CostPerUnit = 5
Markup = 1.05
X = "yes"
MsgBox "The Gross Profit for CD Sales is $" & (SalesPrice _
* UnitsSold) -(UnitsSold * CostPerUnit * Markup)
' Displays the value of 7000 as the gross profit.
End Sub
4.
Create a new workbook and name it
VideoSales.xls
.
5.
.
In Microsoft Excel 97 or later follow these steps to insert a new module sheet and name
the module sheet:
a. In the CDSales.xls workbook, point to
In the
VideoSales.xls
workbook, insert a module sheet. Name the module sheet
VideoSales
Macro
on the
Tools
menu, and then click
Visual Basic Editor
.
b. On the
.
c. In Microsoft Excel for Windows (version 97 and later), you can rename a module by
activating the module, clicking to the right of “(Name)” in the
Insert
menu, click
Module
window of
the Visual Basic Editor, type a new module name, and then press ENTER.
Properties
6.
In the
VideoSales
module sheet, type the following code:
Public SalesPrice As Integer
Public UnitsSold As Integer
Public CostPerUnit As Integer
Sub VideoSales()
SalesPrice = CDSales.SalesPrice * 1.05
UnitsSold = CDSales.UnitsSold * 1.456
CostPerUnit = CDSales.CostPerUnit * 1.75
MsgBox "The Projected Gross Profit for video sales is $" & _
(SalesPrice * UnitsSold) - (UnitsSold * CostPerUnit)
' Displays the value of 5824 as the projected gross profit.
End Sub
F. 3 O RUN THE SAMPLE MACROS IN MICROSOFT EXCEL 5.0, 7.0
1.
To create a reference from the workbook VideoSales.xls to CDSales.xls, select the
Video
Sales
module sheet in
VideoSales.xls
, and then click
References
on the
Tools
menu.
2.
In the
References
dialog box, select the
CDSales.xls
check box, and then click OK.
3.
Run the CDSales macro and then run the VideoSales macro.
Search WWH ::




Custom Search