Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 430
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I want user form to display when opening a work book JohannM Excel Worksheet Functions 1 September 14th 06 12:23 AM
Add a form to excel work book masyasha Excel Programming 1 May 10th 06 09:15 PM
user form for w/book TUNGANA KURMA RAJU Excel Discussion (Misc queries) 2 March 21st 06 04:20 AM
Load form saved in one work book from another. Francis Brown Excel Programming 1 December 11th 05 03:06 PM
Open book, check for macros, close book Robin Hammond[_2_] Excel Programming 5 March 31st 05 06:09 PM


All times are GMT +1. The time now is 07:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"