Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default First Aid For Macros

To remove a module, go to the project explorer in the VBE and right click on
a module in the project tree. Choose Remove and don't export the code if
you don't need it (I assume you would only delete modules you didn't need
and I couldn't imagine that you need 80 modules.).

Dim Target as Range lines, each involving only two lines
of code: Target.FormulaR1C1 = ... ; and Target.Value = Target.Value

These aren't Dim lines (note that dim does not appear in either.) these are
assignment statements.

Dim is to define a variable in terms of scope and type.

sub Macro1()
Dim myvar as Long '<== Dim statement
myvar = 12 '<== Assignment statement
msgbox Myvar '<== command
End sub

--
Regards,
Tom Ogilvy





"Chuckles123" wrote in message
...

I had (fortunately, not have) a sick macro (at least I think HAD). When
opening, and when saving, the workbook containing the macro, I received
"Compile error: Invalid outside procedure" -- on the same screen, a
range name or a cell location in the coding would be highlighted.
Also, when doing Alt+{F8}, the name of the macro with the problem did
NOT appear; furthermore, the other 12 macros listed had the file name
plus the Module number preceding each macro name.

My solution was to copy the macro contents to the Clipboard, delete all
of the text in the problem macro, and then save the workbook. I then
re-opened the workbook (this time there was no problem). I then
created a new macro, re-named it, pasted the text from the Clipboard,
and then saved the workbook.

I have two theories as to what happened:

As I said above, 13 macros; all but one (not the problem macro) of them
are connected, maybe a 1,000 lines of code. Somehow, I have about 80
Modules; I have made numerous macro edits -- I did nothing else that I
am aware of to create these Modules. Is this a problem?

Secondly, I have 3 MsgBoxes in these macros (2 of them are in the
problem macro), each containing Yes and No buttons. Each has the
following line of code: Dim Msg, Style, Title, Response. I think when
I had created only 2 of these boxes, the compiler did not have a
problem. But, when I created the third, the compiler definitely had a
problem -- I deleted one or two of the Dim lines and everything
appeared to work OK.

I also had two Dim Target as Range lines, each involving only two lines
of code: Target.FormulaR1C1 = ... ; and Target.Value = Target.Value (I
think both of these Dim lines are in the same macro, but not the
problem one); the compiler forced me to delete one of these Dim lines.

Are my Dim lines a problem? I would like to create one more MsgBox.

Any help would be appreciated.

Chuckles123


--
Chuckles123
------------------------------------------------------------------------
Chuckles123's Profile:

http://www.excelforum.com/member.php...o&userid=14948
View this thread: http://www.excelforum.com/showthread...hreadid=266313



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
convert lotus 123w macros to excel macros rpiescik[_2_] Excel Programming 1 September 19th 04 12:41 PM
convert lotus 123w macros to excel macros rpiescik Excel Programming 1 September 18th 04 01:35 PM
Open workbook-macros enabled, opening another with macros George J Excel Programming 5 September 17th 04 02:07 PM
Macro Size Limit / open macros with macros? andycharger[_7_] Excel Programming 6 February 13th 04 02:00 PM
Macros not appearing in the Tools Macro Macros list hglamy[_2_] Excel Programming 5 October 24th 03 09:10 AM


All times are GMT +1. The time now is 10:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"