Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Example form Book
This code is right-out-of-the-book:
(In sheet1 Object module) Option Explicit Option Base 1 Dim Sales() As String Sub CommandButton1_Click() Static i As Integer i = i + 1 ReDim Preserve Sales(i) Sales(i) = InputBox("Sales Figures?") End Sub I created using the Control Box a Command Button with (name) CommandButton1 After I click and enter 123 When I go to the Immediate window and Enter ? Sales(i) << and return I get "Compile error" "Sub or Function not defined" What's wrong?? TIA, Jim |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Example form Book
in a general module put in the declaration
Public Sales() as String remove the Dim Sales() as String from the sheet module. You could make a variable public in the sheet module, but it won't allow you to do that with an array. Otherwise, you would need to create a "property get" to return values from the array. If that is what the book is heading for, then you wouldn't want to move the array to a general module. -- Regards, Tom Ogilvy -- Regards, Tom Ogilvy "Jim May" wrote: This code is right-out-of-the-book: (In sheet1 Object module) Option Explicit Option Base 1 Dim Sales() As String Sub CommandButton1_Click() Static i As Integer i = i + 1 ReDim Preserve Sales(i) Sales(i) = InputBox("Sales Figures?") End Sub I created using the Control Box a Command Button with (name) CommandButton1 After I click and enter 123 When I go to the Immediate window and Enter ? Sales(i) << and return I get "Compile error" "Sub or Function not defined" What's wrong?? TIA, Jim |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
I want user form to display when opening a work book | Excel Worksheet Functions | |||
Add a form to excel work book | Excel Programming | |||
user form for w/book | Excel Discussion (Misc queries) | |||
Load form saved in one work book from another. | Excel Programming | |||
Open book, check for macros, close book | Excel Programming |