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
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
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
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0
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..... ;)

 
Upvote 0

Forum statistics

Threads
1,215,036
Messages
6,122,794
Members
449,095
Latest member
m_smith_solihull

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top