View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Baruche Baruche is offline
external usenet poster
 
Posts: 1
Default Problem with "Range"

Using Excel 2002 SP3
This code works:
Sub Zloaddata()
phyfile = ThisWorkbook.Name
phypath = ThisWorkbook.Path & "\"
Workbooks(phyfile).Sheets("PHY").Activate
Workbooks(phyfile).Sheets("PHY").Range(Columns(1), Columns(250)).Delete

This code results in "Run-time error 1004 Application-defined or
Object-defined error"
Sub CommandButton3_Click()
phyfile = ThisWorkbook.Name
phypath = ThisWorkbook.Path & "\"
Workbooks(phyfile).Worksheets("PHY").Activate
ActiveWorkbook.Sheets("PHY").Range(Columns(1), Columns(250)).Delete

Why does the 2nd example result in the run-time error ?