Error:Can't find project or library

C

Casey

Hi,
I recently copied code out of one VBA project and pasted it into a new
project. The code still works fine in the original project, but in the
new project I get the Compile Error:Can't find project or library.
VBA help says this is due to a missing reference and direct me to
"Display the References dialog box", but I can't locate this dialog box
anywhere. Here is my code and the editor highlights "msg =" in the
code. Any help would be greatly appreciated.

Sub DeleteBlankLastRow_CheckIfBlank()
Dim Response As Integer
Dim rngEntryBottomRow As Range

On Error GoTo ws_exit
Application.EnableEvents = False
Application.ScreenUpdating = False
ActiveSheet.Unprotect ("geekk")
Set rngEntryBottomRow = Range("Below_Entry_Bottom_Row").Offset(-1)

'if last detail row is blank, delete one detail row and If not
empty
' then msg box to explain error and exit sub.
If Application.WorksheetFunction.CountA(rngEntryBottomRow) > 5
Then
Msg = MsgBox("You are attempting to Delete a Row that contains
User Input. Delete Row Failed", vbOKOnly + vbCritical, "Can Not Delete
Row with Information")
If Response = 1 Or 2 Then Exit Sub

End If

If Application.WorksheetFunction.CountA(rngEntryBottomRow) = 5
Then
With rngEntryBottomRow 'rngI
..EntireRow.Delete
End With
End If

ActiveSheet.Protect ("geekk"), DrawingObjects:=True,
Contents:=True, Scenarios:=True
Application.ScreenUpdating = True
ws_exit:
Application.EnableEvents = True

End Sub
 
J

Jim Thomlinson

Msg is not declared in a Dim satement. I assume that you have Option Explicit
at the top of this code module (as you should) and that it doe not exist in
the other module where you copied it from. Change Msg to Response which is
delcared and you should be good to go. (To be technically correct Response
should be a long as MsgBox returns a long not an integer but under normal
circumsatances it makes not practical difference.)
 
B

Bob Phillips

Also take a look at Tools>References in the VBE, and see if any checked
items do say Missing.

--

HTH

RP
(remove nothere from the email address if mailing direct)


Jim Thomlinson said:
Msg is not declared in a Dim satement. I assume that you have Option Explicit
at the top of this code module (as you should) and that it doe not exist in
the other module where you copied it from. Change Msg to Response which is
delcared and you should be good to go. (To be technically correct Response
should be a long as MsgBox returns a long not an integer but under normal
circumsatances it makes not practical difference.)
 
C

Casey

Jim,
Your clarivoyance (Option Explicit thing) and your code were both righ
on. Thank you. Follow up if I may. What would be the correct Declaratio
for Msg?

Bob,
Thank you for your input as well. I did go to Tools>References and lo
and behold, a checked reference to TMPLTNUM.XLA is preceeded b
MISSING:.
What should I do here?

Thank both of you for your time
 
J

Jim Thomlinson

I hate to break it to you but the value is never used... Generally it is poor
code... in this instance this would be the most appropriate code...

Then
MsgBox "You are attempting to Delete a Row that contains User Input. " & _
"Delete Row Failed", vbOKOnly + vbCritical, "Can Not Delete " & _
"Row with Information"
Exit Sub

The statement
If Response = 1 Or 2 Then Exit Sub
is evalueated
If (Response = 1) Or (2) Then Exit Sub
Where 2 is not 0 and therefore true...

Here is some code to look at though in case you need to respond to a massage
box

if msgbox("Ok?", vbYesNo) = vbyes then
msgbox "You Pushed Yes"
else
Msgbox "You Pushed No"
end if
 
J

Jim Thomlinson

TmpltNum.xla is the template addin. In Excel choose Tools -> Addins ->
Template Utilities. This will install the addin and clear up the missing
reference...
 
B

Bob Phillips

Casey,

Uncheck and see if anything goes wrong. My money says it won't.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
C

Casey

Jim,
Thank you, I have no pride whatsoever in my programming skills, I'm
still learning from guys like you. Most of what I do is cobbled
together bits and pieces of code gleened from everywhere and I record
Macros and clean'em up. Guys like you and Bob are my online mentors.
And I turn around and go to the New Users group and try and help them
out.
While I was typing this I just a notification of your reply to my
second question. Thank you very much. Have a great weekend.

PS Did'nt have an opportunity to use your idea or Bob's on the
reference problem. Had a need to restart windows and when I got back
the reference along with it's MISSING: tag were gone.
 
C

Casey

Bob,
Got your reply on the reference problem. Between the time I asked th
question originally and now; I loaded some new software and had t
restart. When I returned to Excel and the editor the reference showin
the MISSING: tag was gone through no action on my part. Least that
know about.

Thanks again for all your help, I think this is about the 5th or 6t
time you've saved my bacon
 
B

Bob Phillips

Casey,

Just for your satisfaction, check that workbook project now and see if the
reference to TmpltNum.xla is checked or not. I would venture it is not, and
from this you can deduce that the workbook was probably started on a machine
with the addin installed and somehow a reference was made, but when
transferred to yours, no add-in, reference throws MISSING.

It is usually safe just to uncheck them. Many times they manifest themselves
in odd ways, highlighting the Right or Left function, and saying that it
cannot find the project or library.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top