473,396 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Variable not Defined for excel 2011

Hi All,
I have been working on this assignment for my computer science class and cannot figure out how to fix my code when I get the error message: Variable not Defined in my User form. Here is the section of my code

Option Explicit

'************************************************* ************************************************** **********
'Melissa Nesbitt, CS 106, Fall 2011, Section 1
'Assignment 3
'************************************************* ************************************************** **********
'************************************************* ************************************************** **********
'Create an entry showing the name of Tree, Zone, Price and caluculate the Shipping and Handling
'************************************************* ************************************************** **********

Const REGULAR_SHIPPING As Double = 0.05
Const EXPRESS_SHIPPING As Double = 0.1
Const FERTILIZER As Double = 10
Const TRUNK_WRAP As Double = 4
Const PRE_PRUNING As Double = 8

'************************************************* ************************************************** **********
'Initialize values and labels when the form first loads
'************************************************* ************************************************** **********
Sub UserForm_Initialize()
Worksheets("sales").Activate


'*** initialize captions on option buttons and check boxes
optShared.Caption = "Shared " & Format(REGULAR_SHIPPING, "Percent")
optShared.Caption = "Shared " & Format(EXPRESS_SHIPPING, "Percent")
chkFertilizer.Caption = "Fertilizer" & Format(FERTILIZER, "Currency")
chkTrunkWrap .Caption = "Trunk Wrap" & Format(TRUNK_WRAP, "Currency")
chkPrePruning.Caption = "Pre-Pruning" & Format(PRE_PRUNING, "Currency")

'*** initialize list boxes since the RowSource property is not available on MAC
lstTree.List = Workshets("names").Range("Tree").Value
lstZone.List = Worksheets("names").Range("Zone").Value
End Sub





'************************************************* ************************************************** **********
'Get the data and fill out the columns
'************************************************* ************************************************** **********
Private Sub btnProcess_Click()
Dim Trees As String
Dim zone As String
Dim price As Double
Dim shippingandhandling, FERTILIZER, trunkWrap, prePruning As Double


'*** get tree name and enter in sheet
Tree = lstTree.Value
Cells(2, 1).Value = Tree

'*** get zone name and enter in sheet
zone = lstZone.Value
Cells(2, 2) = zone

'*** get price and enter in sheet
price = CDbl(txtPrice.Value)
Cells(2, 3) = Format(price, "Currency")

'*** compute shipping and handling according to type
If optSolo.Value = True Then
shippingandhandling = price * REGULAR_SHIPPING
ElseIf optShared.Value = True Then
shippingandhandling = price * EXPRESS_SHIPPING
Else 'error, no shipping chosen
MsgBox ("You must choose a shipping cost")
Exit Sub
End If

'***compute any add-ons
If chkFertilizer.Value = True Then
Total = price * shippingCost + FERTILIZER
Else
FERTILIZER = 0
ElseIf chkTrunkWrap.Value = True Then
Total = price * shippingCost + trunkWrap
Else
trunkWrap = 0
ElseIf chkPrePruning.Value = True Then
Total = price * shippingCost + prePruning
Else
prePruning = 0
End If



'*** finish up
Cells.Columns.AutoFit 'adjust column width to fit entries

End Sub



About a quarter of the way down, optShared.Caption is what is highlighted as not defined. Can anyone help?
Oct 19 '11 #1
1 1386
Guido Geurs
767 Expert 512MB
I'm still working with office 2003 but:
- Q1 lstTree.List and lstZone.List are these listboxes ?
If so, .List is not a Property!
- Q2 is in 2011 is the structure of this command correct (I'm getting an error)=

If .. then
else
elseif .. then
else
elseif .. then
else
end if
Oct 19 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Ken Fine | last post by:
I have a Sub which defines a variable. I'm wondering if there's anyway I can get at that variable outside of the context of the Sub -- to pass the variable's contents to another page, for instance....
2
by: MC | last post by:
HI to all, First excuse me but i'm xsl beginner. I'm using XSL to transform an xml file into another. I'm using a Java program for the transformation (TraX API). I would like to recover in...
4
by: Dan Elliott | last post by:
Hello, Converting from a working C program to C++, I run into the following error: I have a header: (header.h) namespace shared{ ... struct X{ ...
4
by: IMS.Rushikesh | last post by:
Hi All, I am trying to execute below code but it gives me an COMException ///// Code Start //// public string GetName(Excel.Range range) { try { if (range.Name != null)
5
by: jeet_sen | last post by:
Hi, My external javascript test.js contains a variable definition var a = "Hello,world!!"; I dynamically loaded the script test.js using the following fucntion: function loadScript(url) { var...
2
by: =?utf-8?B?5Lq66KiA6JC95pel5piv5aSp5rav77yM5pyb5p6B | last post by:
Please see the followed example: class A: def __init__(self): pass class X: def __init__(self): n = 200 if True: j = 200
1
by: Meal | last post by:
Is this safe? foo(C2X("")); C2X is a macro defined as #define C2X(str) XStr(str).unicodeForm() XStr is a kind of string processing class. unicodeForm() returns pointer of its member string.
6
by: emsik1001 | last post by:
Hi Everyone I want to fire a stored procedures (SQL Server 2000) from Excel using SQLCMD but I want to be able to change the variable value by typing it in the 'parameter value' box. Many...
1
by: arsha123 | last post by:
How can I change the value of empty session variable with another variable value defined in form. I get value of session value of id from a logon form , that is "". I have defined a variable in form...
3
by: kino | last post by:
Hello, I have a variable in a ".cs.aspx" file and I want to use it in the same page's ".aspx" file, I tried using Reponse.Write with the help of the syntax: <%Response.Write(var)%> But it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.