Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Pass Object from UserForm to Code Module

Excellent! Much more efficient. Many Many thanks!
--
Programmer on Budget


"p45cal" wrote:


Budget Programmer;477115 Wrote:
Hi P45cal. I appreciate your help very much. I coped your code and it
works
fine. But I'm back to my original problem. How do I call UserForm
FROM MY
FIRST EXECUTED MODULE (My "Driver" module) and receive back the
collection
called "x"? I tried DIM'ing "x" as "Public x as Collection" in the
UserForm,
but it that wouldn't work either. The only code is a driver module and
the
userform (There's no code in the Worksheets.
Many Thanks for all your help.
--
Programmer on Budget


This in a standard code module:Sub driver()
UserForm1.Show ' ShowModal property has to be set to True for this
userform
Dim x As New Collection
With UserForm1.ListBox1
For i = 0 To .ListCount - 1
If .Selected(i) Then x.Add Sheets(.List(i))
Next i
'x now has your collection of sheets
End With
blah x
Unload UserForm1
'x here still has your collection of sheets
'Set x = Nothing'later, for housekeeping
End Sub

Sub blah(shs)
For Each mysht In shs
mysht.Activate
MsgBox mysht.Name & " active now?"
Next mysht
End Sub
and this behind the userform:Private Sub
UserForm_Initialize()
For Each Sht In ThisWorkbook.Sheets
ListBox1.AddItem Sht.Name
Next Sht
End Sub
Private Sub CommandButton1_Click()
UserForm1.Hide
End Sub


--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=131480


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
Call a sub in a modeless userform from a code module? fedude Excel Programming 5 May 30th 09 03:15 AM
Pass worksheet object name to a class module [email protected] Excel Programming 1 May 9th 07 12:48 PM
Pass variable from module to userform and back [email protected] Excel Programming 0 July 20th 06 04:46 PM
Code in userform/worksheet vs. in Module davegb Excel Programming 2 June 19th 06 04:17 PM
How to pass values from a userform to a standard module? TBA[_2_] Excel Programming 3 January 7th 04 01:50 PM


All times are GMT +1. The time now is 03:13 AM.

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

About Us

"It's about Microsoft Excel"