Trim: Excel 97 gives error "Can't find project or library"

J

Jim Mooney

I don't know why Trim(...) function does not work in the
Excel programming section of a worksheet for Excel 97. I
also have a copy of Office 2003 and it works fine with
this version.

How do I convert this statement in Office 2003:

Name = Trim(Name)

to work in Office97? The error keeps coming up:

Can't find project or library

Trim is highlighted.
 
H

Haldun Alay

Hi,

Try Name=WorksheetFunction.Trim(Name)

Kind regards.

--
Haldun Alay


"Jim Mooney" <[email protected]>, iletide sunu yazdi I don't know why Trim(...) function does not work in the
Excel programming section of a worksheet for Excel 97. I
also have a copy of Office 2003 and it works fine with
this version.

How do I convert this statement in Office 2003:

Name = Trim(Name)

to work in Office97? The error keeps coming up:

Can't find project or library

Trim is highlighted.
 
B

Bob Phillips

Jim,

Try going into Tools>References in the VBE, and see if there is a Missing
reference in the list. If there is, uncheck it. You may need to browse for
the correct version to ensure that things still work.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
G

Guest

I did encounter a similar problem with Excel 2003 when using the Option
Explicit statement at the beginning of the program. I had a ClearSheet
subroutine which used statements like:

Range("A2:J345") = xlClearContents

This statement works when not using the Option Explicit statement but does
not when I use the Option Explicit statement. Does Excel 97 have this option
automatically enabled and if so is there a way to disable it? Or is there
another solution to this problem?
 
N

Norman Jones

Hi Jim,

The use of Option Explicit is optional but *highly* desirable.

To set the default to non-use, in the VBE :

Tools | Options | Editor | Require Variable Declararion <== Uncheck


With Option Explicit invoked,
Range("A2:J345") = xlClearContents

errors because,syntatically, this should be:

Range("A2:J345").ClearContents


Regards,
Norman
 
N

Norman Jones

Hi Jim,
The References Option is greyed out and I am unable to select it.

This would happen if you are in break mode - press the macro reset button
and then try Bob's suggestion.
 
T

Tom Ogilvy

it actually errors (with option explicit) because there is no predefined
constant

xlClearContents

if he declared

Dim xlClearContents as Variant

then it would work fine althought the use of the clearcontents method (as
you point out) is the provided method and probably should be employed.
 
T

Tom Ogilvy

How many are checked now <shudder>

There shouldn't be more than 5 checked (of course which 5 would be
important).
 

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