Thread: For Each Loop
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Matt[_21_] Matt[_21_] is offline
external usenet poster
 
Posts: 11
Default For Each Loop

Could someone tell me why the following sub will not paset each book name
and sheet to its own workbook and sheet. I am obvously doing something
wrong but don't know what.


Sub TestSub()

Dim wk As Workbook
Dim ws As Worksheet


For Each wk In Workbooks
For Each ws In Worksheets
ws.Cells(1, 1) = ws.Name
ws.Cells(3, 1) = wk.Name
Next ws
Next wk



End Sub