Compile error: sub or function not defined

matze

New Member
Joined
Feb 23, 2010
Messages
5
hi there,

once again i've got a problem.
i want to export a single sheet of my workbook into a new workbook. therefore i've got the following code:

Code:
sheets("Channel").Copy
ActiveWorkbook.SaveAs fileName:="C:\test.xls"
ActiveWorkbook.Close


but if i run that sub, i get this error:

Compile error:
Sub or function not defined!


furthermore vba marks the line

Code:
call WriteManifoldResults


as i am a bloody beginner i would guess the error occurs because of some functions linked to the sheet i want to export. so my questions basicly are:

1) is it because of the links leading to the sheet?
2) how can i solve this problem

thank you very much
i'd be absolutly thankful for every little help.

cheers

matthias
 

Some videos you may like

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

wigi

Well-known Member
Joined
Jul 10, 2006
Messages
7,953
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
  3. Web
Did you surround this piece:

Code:
sheets("Channel").Copy
ActiveWorkbook.SaveAs fileName:="C:\test.xls"
ActiveWorkbook.Close

with a name for the procedure?

Code:
Sub [I]MyProcedure[/I]()
sheets("Channel").Copy
ActiveWorkbook.SaveAs fileName:="C:\test.xls"
ActiveWorkbook.Close
End Sub
 

Yard

Well-known Member
Joined
Nov 5, 2008
Messages
1,929
Looks like your code is trying to call a procedure called WriteManifoldResults which doesn't exist in your project. Either:

- delete the line which calls it (bearing in mind this could have knock-on effects)
or
- re-establish the WriteManifoldResults procedure in your project so it gets called successfully

HTH
 

matze

New Member
Joined
Feb 23, 2010
Messages
5
well, actually the programme works perfectly if i - in example - save the whole workbook under a new name or export not the whole sheet but one of its charts. usually the "Call Writemanifold"-line works without problems. that's why i guess it has to do with the links. strange excel.
 

Yard

Well-known Member
Joined
Nov 5, 2008
Messages
1,929
So maybe the code which is calling the Writemanifold sub is not in the same workbook as the Writemanifold itself?

As per wigi's question, you haven't explained where your code sits so it's a bit hard to figure out why it's going wrong.

I'm not convinced this is some "strange" behaviour on Excel's part..... ;)

 

Watch MrExcel Video

Forum statistics

Threads
1,118,578
Messages
5,573,029
Members
412,499
Latest member
Aread62127
Top