error when using variable name for workbook

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am getting an error here:

Sheets("Sheet1").Copy After:=Windows(sFile).Sheets(1)

which says that

"Object doesn't support this property or method"

Here is the code that I used:

Call GetContractFileName

Workbooks.Open
FileName:="G:\USER\Contracts\Data_Files\All_2004_Catalog.xls"
sFile = contractfilename
cntNo = ContractNo
Sheets("Sheet1").Copy After:=Windows(sFile).Sheets(1)
Windows(sFile).Activate
Sheets(cntNo).Select
_____________________________________
Public Function GetContractFileName()
ContractNo = InputBox("Enter the Contract Number: ", "Contract File")
contractfilename = ContractNo & ".xls"

End Function
 
have you wrote declaration for contractfilename variable in declarations
section?
that must be done to use variables between subs..

"Emma" kirjoitti:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top