Ms excel error

I am trying khổng lồ Điện thoại tư vấn a sub on a different worksheet but I got a run time error message.

Specifically, I have two worksheets và multiple VBA sub s in those worksheets. In one of the VBA Project (say workbook1.xlsm), I have the following code:

Sub AnalysisTableMacro()Workbooks("Pynhỏ bé solution macro.xlsm").ActivateApplication.Run "Pydong dỏng solution macro.xlsm!.PreparetheTables"End SubBut I got the following error. The macros on both worksheets are enabled. In both worksheets, the subs are in Module1.

Cannot run the macro "Workbook.xlsm!PrepareTheTables". The macro may not be available in >this workbook or all macros may be disabled.

Bạn đang xem: Ms excel error

I also tried Application.Run "Pythanh mảnh solution macro.xlsm!Module1.PreparetheTables" but did not work.


excel vcha
Share
Improve this question
Follow
edited Feb 19 "19 at 18:31
*

TylerH
19.4k5151 gold badges6565 silver badges8686 bronze badges
asked Aug 22 "13 at 19:47
*

Ege OzlemEge Ozlem
77322 gold badges88 silver badges77 bronze badges
0
Add a comment |

13 Answers 13


Active Oldest Votes
21
If you have sầu a space in the name of the workbook you must use single quotes (") around the tệp tin name. I have sầu also removed the full stop.

Application.Run ""Pynhỏ bé solution macro.xlsm"!PreparetheTables"
Share
Improve this answer
Follow
answered Mar 7 "16 at 15:55

*

ChipsLettenChipsLetten
2,88111 gold badge99 silver badges2727 bronze badges
0
Add a phản hồi |
7
Had the same issue and I "Compiled VBA Project" which identified an error. After correction and compiling, the macros worked.


Share
Improve this answer
Follow
answered Sep 4 "16 at 3:53
*

VigneshVignesh
15722 silver badges1212 bronze badges
Add a comment |
7
You also run into lớn this issue when you are creating routine in a class module.

When you try to lớn run the code externally, you get this error.You can"t assign macro to button lớn a thành viên of a class module either.

If you try lớn run from within the code by pressing green play button you will also see the same error.

Either move sầu the routine in to a regular module or create a new routine in a regular module that calls the class member.


Share
Improve this answer
Follow
edited May 22 "18 at 0:47
*

HackSlash
3,48722 gold badges1414 silver badges3434 bronze badges
answered May 11 "18 at 13:39
Heap of Pinlớn BeansHeap of Pinto Beans
61711 gold badge99 silver badges1919 bronze badges
0
Add a phản hồi |
7
In my case this error came up when the Sub name was identical lớn the Module name.


Share
Improve sầu this answer
Follow
answered May 25 "19 at 19:11
Mor SagmonMor Sagtháng
56511 gold badge1010 silver badges2828 bronze badges
1
Add a bình luận |
6
Per Microsoft"s KB, try allowing programmatic access khổng lồ the Visual Basic project:

Click the Microsoft Office Button, and then clichồng Excel Options. Click Trust Center. Cliông xã Trust Center Settings. Clichồng Macro Settings. Cliông chồng lớn select the Trust access to lớn the VBA project object Model check box. Click OK khổng lồ cthua thảm the Excel Options dialog box. You may need to close & re-open excel.
Share
Improve this answer
Follow
edited Feb 9 "16 at 15:18
Jess
20.9k1818 gold badges112112 silver badges130130 bronze badges
answered Jan 17 "14 at 0:42
Ved RaiVed Rai
10911 silver badge33 bronze badges
2
Add a bình luận |
2
In my case the error happened when I placed my macro (public sub) inkhổng lồ a ThisWorkbook section of the file expecting it will make it visible for Application.Run function. This was not the case & I got that error you mentioned.

I moved my macro inkhổng lồ a separate Module và it resolved the problem.

Xem thêm: Lựa Chọn Kích Thước Bàn Thờ Ông Địa Thần Tài, Theo Tuổi Đem Lại


Share
Improve this answer
Follow
answered Aug 7 "19 at 17:55
Peter LiapinPeter Liapin
1,00688 silver badges1717 bronze badges
Add a phản hồi |
2
I had a problem with this error as well, turned out the the filename was causing the problem.

I was calling it lượt thích this:Application.Run """ và strPath và strFName & ""!UPC.PrintaFew"

The variable strFName contained an apostrophe in it which, of course messed things up. Took me hours to figure it out. But once the apostrophe was removed from the filename it worked.


Share
Improve sầu this answer
Follow
edited Jan 3 "20 at 16:17
pgSystemTester
5,09822 gold badges1414 silver badges4040 bronze badges
answered Sep 1 "17 at 11:13
JovialJohnJovialJohn
2511 silver badge44 bronze badges
Add a bình luận |
1
I had lớn remove all dashes and underscores from tệp tin names và macro names, make sure that macro were enabled and add them module name.macro name

This is what I ended up with: Application.Run (""" và WbName & """ & "!ModuleName.MacroName")


Share
Improve sầu this answer
Follow
edited Jan 3 "20 at 16:18
pgSystemTester
5,09822 gold badges1414 silver badges4040 bronze badges
answered Aug 3 "17 at 20:58
Matt R.Matt R.
1111 bronze badge
Add a comment |
1
Go into lớn task manager & see if you have sầu any Microsoft Excel Processes running in the background. I closed my excel background processes and my code worked again.


Share
Improve sầu this answer
Follow
answered Jan 7 "20 at 18:45
Brennan CaseyBrennan Casey
76711 gold badge66 silver badges1717 bronze badges
1
Add a comment |
0
Delete your name macro & build again.I did this, và the macro worked.


Share
Improve this answer
Follow
edited Oct 6 "13 at 0:17
Michael Petrotta
57.3k2626 gold badges137137 silver badges175175 bronze badges
answered Oct 5 "13 at 23:50
Dhitta HanandaDhitta Hanandomain authority
922 bronze badges
1
Add a phản hồi |
0
I had the same problem as OP và found was due to the options declaration being misspelled:

" Comment bình luận Options Explicit Sub someMacroMakechart()in a sub module, instead of correct;

" Comment bình luận Option Explicit Sub someMacroMakechart()
Share
Improve this answer
Follow
answered Jan 21 "16 at 5:04
DoyletDoylet
911 bronze badge
Add a bình luận |
0
This error also occurs if you create a sub or function in a "Microsoft Excel Object" (like Sheet1, Sheet2, ...) instead to lớn create it in a Module.

For example:you create with VBA a button and mix .OnAction = "btn_action" . And Sub btn_action you placed into lớn the Sheet object instead inkhổng lồ a Module.


Share
Improve this answer
Follow
answered Nov 6 "19 at 18:50
elano7elano7
42711 gold badge44 silver badges1111 bronze badges
Add a phản hồi |
0
I had the same error message "Cannot find the macro ___ etc" and this problem persisted even after I"d saved the tệp tin as an XLSX. This seemed very odd ... how could it be running a macro when the file has no macros!

When I examined the tệp tin using the Custom UI Editor, I found that a macro was being called when the tệp tin was initialized và another custom macro was being called when the user clicked the Save button.

Using the Custom UI Editor, I removed all the XML code và the error messages disappeared.


Share
Improve this answer
Follow
answered May đôi mươi "đôi mươi at 4:07
Jeff RobsonJeff Robson
1333 bronze badges
Add a bình luận |
Highly active question. Earn 10 reputation (not counting the association bonus) in order khổng lồ answer this question. The reputation requirement helps protect this question from spam and non-answer activity.

Not the answer you're looking for? Browse other questions tagged excel vcha or ask your own question.


The Overflow Blog
Featured on Meta
Linked
1
Couldn't exexinh đẹp Excel Macro using Python
0
Why won't Pykhiêm tốn run a macro in Excel using the code below?
0
“Cannot run the macro (…). The macro may not be available in this workbook or all macros may be disabled.”
1
Cannot run the macro … from SSIS
0
Excel Cannot Run Macro
0
VBA - Cđại bại “ThisWorkbook”, và re-open after Delay
-1
Passing variables from QTP/UFT lớn Excel macros
0
Why would a macro from a different workbook be inaccesible after allowing macro's?
Related
3
Macro Fails, 'The macro may not be available in this…'
0
Error 1004 after restart: macro may not be available in this workbook or all macros may be disabled
0
Can not run the macro xx. may not be available in this workbook or all macros are disabled
0
Cannot run the macro. The macro may not be availabe in this workbook
3
VBA Application.Run returns error 1004 The macro may not be available in this workbook or all macros may be disabled
1
Running an Excel macro from another workbook
Hot Network Questions more hot questions
Question feed
Subscribe to RSS
Question feed To subscribe lớn this RSS feed, copy và paste this URL inlớn your RSS reader.


lang-vb
Staông chồng Overflow
Products
Company
Staông chồng Exchange Network
site thiết kế / biệu tượng công ty © 2021 Staông chồng Exchange Inc; user contributions licensed under cc by-sa. rev2021.8.13.39972


Staông chồng Overflow works best with JavaScript enabled
*

Your privacy

By clicking “Accept all cookies”, you agree Staông chồng Exchange can store cookies on your device và discchiến bại information in accordance with our Cookie Policy.