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

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

wigi

Well-known Member
Joined
Jul 10, 2006
Messages
7,964
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..... ;)

 

Forum statistics

Threads
1,171,630
Messages
5,876,546
Members
433,199
Latest member
guerin47

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
Top