Re: $$Excel-Macros$$ vba excel understanding objects : worksheet

2010-09-24 Thread Lotta
HI, The easiest way to loop worksheets would be: Dim ws as worksheet Dim wbk as workbook Dim wbk as workbook 'assign your workbooks to files for each ws in wbk.worksheets next ws On 24 Sep, 00:55, cyber 1000s cyber10...@gmail.com wrote: Hi, I'm looking for a more general answer about objects

Re: $$Excel-Macros$$ vba excel understanding objects : worksheet

2010-09-24 Thread Lotta
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

Re: $$Excel-Macros$$ vba excel understanding objects : worksheet

2010-09-24 Thread r
is not possible. Worksheets is a set of dependent objects of workbook. use the Properity WorkShets is the only way to return this set. viceversa you could use a array of worksheet Sub test() Dim wb As Workbook Dim ws As Worksheet Dim wss() As Worksheet Dim l As Long Set wb = ThisWorkbook For

Re: $$Excel-Macros$$ vba excel understanding objects : worksheet

2010-09-24 Thread r
Alternatively you can also use a Collection with the advantage of using also the key in item, more to index: Sub test2() Dim wb As Workbook Dim ws As Worksheet Dim colWs As New Collection Set wb = ThisWorkbook For Each ws In wb.Worksheets colWs.Add ws, ws.Name Next Set ws =

$$Excel-Macros$$ vba excel understanding objects : worksheet

2010-09-23 Thread cyber 1000s
Hi cyberspace, I have some c programming background... Is it possible to increment a worksheet object (worksheets collection) in a loop such as below ? Public Sub CopyShNamesFromWkbToWkb2() Dim i As Integer Dim wkb As Object Set wkb = Workbooks(Nouveau_Feuille_Excel_1.xls) Dim wkb2 As

Re: $$Excel-Macros$$ vba excel understanding objects : worksheet

2010-09-23 Thread roberto mensa
you need to use: Property Worksheets As Sheets of Excel.Workbook Public Sub CopyShNamesFromWkbToWkb2() Dim i As Long Dim wkb As Excel.Workbook Dim wkb2 As Excel.Workbook Set wkb = Workbooks(Nouveau_Feuille_Excel_1.xls) Set wkb2 = Workbooks(Classeur1.xls) 'Dim ws As Object 'Set ws =

Re: $$Excel-Macros$$ vba excel understanding objects : worksheet

2010-09-23 Thread roberto mensa
For i = 1 To wkb.Worksheets.Count Fix this line regards r -- -- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN

Re: $$Excel-Macros$$ vba excel understanding objects : worksheet

2010-09-23 Thread r
On 23 Set, 12:28, roberto mensa robb@gmail.com wrote:  For i = 1 To wkb.Worksheets.Count Fix this line regards r g :-) i'm sorry, so ... For i = 1 To wkb2.Worksheets.Count regard r -- -- Some

Re: $$Excel-Macros$$ vba excel understanding objects : worksheet

2010-09-23 Thread cyber 1000s
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?).