View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default 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