LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default Code not working when transfered into Userform

I have this code which is not working. As presented
below it works fine. Sub One Sets a public array. It
then Calls Sub Two and I print values to the Immediate
Window.

Now I cannot seem to get this to work when I put this
code into a useform. I put the Option Explicit and
Public Array Declaration at the top of the page. Then I
put Sub One into a Private Sub OKButton_ClickEvent(). I
then put Sub Two into a Private Sub as well on the same
form. When I run it I get an Error 424 Object Required
within what was Sub Two. On the line:

For Each A In vArray(X)

The code can't seem to make sense of the variable A. Yet
it presents no problems when modelled as seen below. Why
does it not work?


Option Explicit
Public vArray As Variant

Sub One()
ReDim vArray(0 To 2)
Set vArray(0) = ActiveSheet.UsedRange
Set vArray(1) = ActiveSheet.Comments
Set vArray(2) = ThisWorkbook.Worksheets
Call Two

End Sub

Sub Two()
Dim A As Object
Dim X As Integer

With ActiveWorkbook
For X = 0 To 2
'Unload public array and pass to A and B as Types
'How do you pass these to A and B??????
For Each A In vArray(X)
' Call Procedure2
Debug.Print X, TypeName(A), TypeName(vArray(X))
Next
Next
End With
End Sub

Immediate Window Values:
0 Range Range
2 Worksheet Sheets
2 Worksheet Sheets
2 Worksheet Sheets
 
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
auto saving transfered data seags Excel Discussion (Misc queries) 2 February 4th 06 12:19 PM
Saving transfered data seags Excel Worksheet Functions 0 January 31st 06 01:21 AM
Keeping a transfered value the same after changing the original va DeVon Excel Worksheet Functions 0 February 4th 05 07:23 AM
Unloading UserForm not working Marston Excel Programming 2 August 17th 04 04:18 AM
Userform not working jrh Excel Programming 1 March 4th 04 09:51 AM


All times are GMT +1. The time now is 12:50 AM.

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"