View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Ian Ripsher Ian Ripsher is offline
external usenet poster
 
Posts: 1
Default Object required confusion

Only use the Set keyword when you're assigning a value to an object
variable. Copy is a worksheet method that doesn't return a reference to an
object (even though you've just used it to create a new object).

"Stuart" wrote in message
...
In the following I receive an 'Object required' error
on the line 'Set ws2 etc'. Why is this, please?

For Each ws In Workbooks(SourceWorkbook).Worksheets
With ws
If Not (UCase(.Name) = "MASTER") Then
With wb
Set ws2 = wb.Worksheets("MASTER").Copy(After:= _
wb.Sheets(wb.Sheets.Count))
ws2.Name = ws.Name
etc

The copy is made when stepping through, but only after the
error message is displayed.

Regards.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.500 / Virus Database: 298 - Release Date: 10/07/2003