Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Cells.Find wont work with "-"

Hello,

I have a confusing problem with some VBA I have written for MS Excel.

I am using the find function as shown below

Cells.Find(What:="a-", After:=ActiveCell, LookIn:=xlValues, LookAt
_
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate

This works perfectly with

What:="a"

but not when i add the "-".

I have had this working with "a-" on another computer also which makes
it even more confusing.

Might I be missing a VBA reference library, there are so many I dont
know how to tell which I might be missing.

OS: Windows NT
Excel: 2000

thanks in advance...

A

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 380
Default Cells.Find wont work with "-"

Works fine for me with XL2000, XP.

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

wrote in message
ps.com...
Hello,

I have a confusing problem with some VBA I have written for MS Excel.

I am using the find function as shown below

Cells.Find(What:="a-", After:=ActiveCell, LookIn:=xlValues, LookAt
_
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate

This works perfectly with

What:="a"

but not when i add the "-".

I have had this working with "a-" on another computer also which makes
it even more confusing.

Might I be missing a VBA reference library, there are so many I dont
know how to tell which I might be missing.

OS: Windows NT
Excel: 2000

thanks in advance...

A



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Cells.Find wont work with "-"

Sub abc()
Dim rng As Range
Dim rng1 As Range
Dim sAddr As String
Set rng = Cells.Find(What:="a-", _
After:=ActiveCell, _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not rng Is Nothing Then
sAddr = rng.Address
Do
If Not rng1 Is Nothing Then
Set rng1 = Union(rng1, rng)
Else
Set rng1 = rng
End If
Set rng = Cells.FindNext(rng)
Loop While rng.Address < sAddr
rng1.Select
msgbox "found at " & rng1.Address

Else
MsgBox "Not found"
End If
End Sub

worked fine for me.
It even found cells where the "-" was produced by formatting.

--
Regards,
Tom Ogilvy


" wrote:

Hello,

I have a confusing problem with some VBA I have written for MS Excel.

I am using the find function as shown below

Cells.Find(What:="a-", After:=ActiveCell, LookIn:=xlValues, LookAt
_
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate

This works perfectly with

What:="a"

but not when i add the "-".

I have had this working with "a-" on another computer also which makes
it even more confusing.

Might I be missing a VBA reference library, there are so many I dont
know how to tell which I might be missing.

OS: Windows NT
Excel: 2000

thanks in advance...

A


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
How do I "insert copied cells"? used to be "alt i e" still work Inserter Excel Worksheet Functions 1 February 14th 09 10:06 PM
Find formatting doesn't work: "Excel cannot find data" Kasama Excel Discussion (Misc queries) 1 August 18th 06 01:40 PM
Format cells wont let me "0.00 g" Bruno Excel Discussion (Misc queries) 2 July 31st 06 09:13 PM
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 AM
Checkbox1.LinkedCell = ActiveCell "Why wont this work?& TimeTraveller - ExcelForums.com Excel Programming 2 September 11th 04 09:05 PM


All times are GMT +1. The time now is 05:11 PM.

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

About Us

"It's about Microsoft Excel"