Hi,

I think the easiest way to loop though worksheets is:
Ex.
Dim ws as worksheet
 ...
i = i+1
For Each ws In wbk2.Worksheets
    wbk.Sheets(3).Cells(i, 4) = ws.name
     i = i+1
Next ws

But in your example you need to use the item property of the
worksheets collection to access the sheet via an index number.
Ex.
wkb2.ws.item(i).Name

I think that if you look at the ws object (worksheets object) in the
watch window, you'll see all the properties of the collection and its
sheets (items).

BR/ Lotta


On 24 Sep, 00:55, cyber 1000s <cyber10...@gmail.com> wrote:
> Hi,
>
> I'm looking for a more general answer about objects in vba like :
>
> dim ws as object
> set ws = worksheets
>
> For i = 1 To wkb.Worksheets.Count
>   wkb.Sheets(3).Cells(i, 4) = wkb2.Worksheets(i).Name
>
> It's ok until the last line, i understand what little there is to
> understand (pointed notation?).
> But is there any reason why instead of   wkb2.Worksheets(i).Name i
> can't have wkb2.ws(i).Name ?
>
> Thx
>
> On Sep 23, 12:08 pm, r <robb....@gmail.com> wrote:
>
>
>
> > On 23 Set, 12:28, roberto mensa <robb....@gmail.com> wrote:
>
> > > >  For i = 1 To wkb.Worksheets.Count
>
> > > Fix this line
> > > regards
> > > r
>
> > grrrr :-)
> > i'm sorry, so ...
>
> > For i = 1 To wkb2.Worksheets.Count
>
> > regard
> > r- Dölj citerad text -
>
> - Visa citerad text -

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
HELP US GROW !!

We reach over 7000 subscribers worldwide and receive many nice notes about the 
learning and support from the group.Let friends and co-workers know they can 
subscribe to group at http://groups.google.com/group/excel-macros/subscribe

Reply via email to