try this out:
ThisWorkbook.Worksheets(1)
hope that helps!
-PtG
Main Topics
Browse All TopicsHi,
I am trying to use a replace function to replace a field's "," character with spaces. It gives me a compilation error saying Replace function not defined. is there any specific reference that I need to add for using replace functions?. I am using TRIM without any trouble. Can someone suggest any better alternative
Thanks
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Replace(...) by itself isn't a valid function in VBA for Office 97... below is an excerpt from the Microsoft Excel Visual Basic help file:
--------------------------
Syntax
expression.Replace(What, Replacement, LookAt, SearchOrder, MatchCase, MatchByte)
expression Required. An expression that returns a Range object.
--------------------------
Thus, "expression" is required, and generally you'll use this function as in my previous post. If you want to just replace values in a normal string without using Ranges and whatnot, you'll have to write your own little Replace function, as below:
Public Function replaceStr(ByVal str1 As String, ByVal repThis As String, ByVal withThis As String) As String
While Left(str1, Len(repThis)) = repThis
str1 = withThis & Mid(str1, Len(repThis) + 1)
Wend
While InStr(2, str1, repThis) > 0
i = InStr(2, str1, repThis)
str1 = Left(str1, i - 1) & withThis & Mid(str1, i + Len(repThis))
Wend
replaceStr = str1
End Function
hope that helps!
-PtG
Business Accounts
Answer for Membership
by: AzraSoundPosted on 2003-08-20 at 13:38:23ID: 9191170
Try specifying the VBA library as well, e.g.,
VBA.Replace(...)