PC Review


Reply
Thread Tools Rate Thread

creating a new collection

 
 
=?Utf-8?B?U3RlZmk=?=
Guest
Posts: n/a
 
      14th Dec 2006
Hi All,

I'm trying to create a new collection containing all worksheets in the
active workbook except the last one, but I failed. Please help!

Regards,
Stefi

 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      14th Dec 2006
Sub NewCollection()
Dim wsColl As Collection
Dim ws As Worksheet

Set wsColl = New Collection
For Each ws In ActiveWorkbook.Worksheets
If ws.Index <> ActiveWorkbook.Worksheets.Count Then
wsColl.Add ws.Name, ws.Name
End If
Next ws
End Sub

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"Stefi" <(E-Mail Removed)> wrote in message
news:A1916D63-1FCB-4032-84E5-(E-Mail Removed)...
> Hi All,
>
> I'm trying to create a new collection containing all worksheets in the
> active workbook except the last one, but I failed. Please help!
>
> Regards,
> Stefi
>



 
Reply With Quote
 
=?Utf-8?B?U3RlZmk=?=
Guest
Posts: n/a
 
      14th Dec 2006
Thanks Bob! Another question: Isn't it possible to set a new collection to an
existing one, I mean something like this:

Dim wsColl As Collection
Set wsColl = ActiveWorkbook.Worksheets

Regards,
Stefi

„Bob Phillips” ezt *rta:

> Sub NewCollection()
> Dim wsColl As Collection
> Dim ws As Worksheet
>
> Set wsColl = New Collection
> For Each ws In ActiveWorkbook.Worksheets
> If ws.Index <> ActiveWorkbook.Worksheets.Count Then
> wsColl.Add ws.Name, ws.Name
> End If
> Next ws
> End Sub
>
> --
> ---
> HTH
>
> Bob
>
> (change the xxxx to gmail if mailing direct)
>
>
> "Stefi" <(E-Mail Removed)> wrote in message
> news:A1916D63-1FCB-4032-84E5-(E-Mail Removed)...
> > Hi All,
> >
> > I'm trying to create a new collection containing all worksheets in the
> > active workbook except the last one, but I failed. Please help!
> >
> > Regards,
> > Stefi
> >

>
>
>

 
Reply With Quote
 
Tom Ogilvy
Guest
Posts: n/a
 
      15th Dec 2006
Dim wsColl As worksheets
Set wsColl = ActiveWorkbook.Worksheets

--
Regards,
Tom Ogilvy


"Stefi" <(E-Mail Removed)> wrote in message
news:31DAAA87-C940-4F37-831B-(E-Mail Removed)...
> Thanks Bob! Another question: Isn't it possible to set a new collection to
> an
> existing one, I mean something like this:
>
> Dim wsColl As Collection
> Set wsColl = ActiveWorkbook.Worksheets
>
> Regards,
> Stefi
>
> "Bob Phillips" ezt rta:
>
>> Sub NewCollection()
>> Dim wsColl As Collection
>> Dim ws As Worksheet
>>
>> Set wsColl = New Collection
>> For Each ws In ActiveWorkbook.Worksheets
>> If ws.Index <> ActiveWorkbook.Worksheets.Count Then
>> wsColl.Add ws.Name, ws.Name
>> End If
>> Next ws
>> End Sub
>>
>> --
>> ---
>> HTH
>>
>> Bob
>>
>> (change the xxxx to gmail if mailing direct)
>>
>>
>> "Stefi" <(E-Mail Removed)> wrote in message
>> news:A1916D63-1FCB-4032-84E5-(E-Mail Removed)...
>> > Hi All,
>> >
>> > I'm trying to create a new collection containing all worksheets in the
>> > active workbook except the last one, but I failed. Please help!
>> >
>> > Regards,
>> > Stefi
>> >

>>
>>
>>



 
Reply With Quote
 
=?Utf-8?B?U3RlZmk=?=
Guest
Posts: n/a
 
      15th Dec 2006
Many thanks, Tom, this is the very method I was looking for.
Stefi


„Tom Ogilvy” ezt *rta:

> Dim wsColl As worksheets
> Set wsColl = ActiveWorkbook.Worksheets
>
> --
> Regards,
> Tom Ogilvy
>
>
> "Stefi" <(E-Mail Removed)> wrote in message
> news:31DAAA87-C940-4F37-831B-(E-Mail Removed)...
> > Thanks Bob! Another question: Isn't it possible to set a new collection to
> > an
> > existing one, I mean something like this:
> >
> > Dim wsColl As Collection
> > Set wsColl = ActiveWorkbook.Worksheets
> >
> > Regards,
> > Stefi
> >
> > "Bob Phillips" ezt *rta:
> >
> >> Sub NewCollection()
> >> Dim wsColl As Collection
> >> Dim ws As Worksheet
> >>
> >> Set wsColl = New Collection
> >> For Each ws In ActiveWorkbook.Worksheets
> >> If ws.Index <> ActiveWorkbook.Worksheets.Count Then
> >> wsColl.Add ws.Name, ws.Name
> >> End If
> >> Next ws
> >> End Sub
> >>
> >> --
> >> ---
> >> HTH
> >>
> >> Bob
> >>
> >> (change the xxxx to gmail if mailing direct)
> >>
> >>
> >> "Stefi" <(E-Mail Removed)> wrote in message
> >> news:A1916D63-1FCB-4032-84E5-(E-Mail Removed)...
> >> > Hi All,
> >> >
> >> > I'm trying to create a new collection containing all worksheets in the
> >> > active workbook except the last one, but I failed. Please help!
> >> >
> >> > Regards,
> >> > Stefi
> >> >
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Collection problems (create Collection object, add data to collection, bind collection to datagrid) yvind Isaksen Microsoft ASP .NET 1 18th May 2007 10:24 AM
Collection problems (create Collection object, add data to collection, bind collection to datagrid) yvind Isaksen Microsoft Dot NET 1 18th May 2007 10:24 AM
Creating a new collection from an existing collection marcus.wade@smart-rs.com Microsoft VB .NET 5 8th Aug 2005 05:47 PM
Creating a new collection from an existing collection marcus.wade@smart-rs.com Microsoft VB .NET 2 3rd Aug 2005 12:43 PM
Help in creating a collection class Matthew Hood Microsoft Dot NET 1 1st Jul 2003 08:24 AM


Features
 

Advertising
 

Newsgroups
 


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