Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using Worksheet Function Find in VBA

I am trying to use the worksheetfunction find to establish whether
text string contains a comma or not (refer below)

testComma = WorksheetFunction.Find(",", ResultsValue, 1)

I have also tried

testComma = iserror(WorksheetFunction.Find(",", ResultsValue, 1))

However, if the string does not contain a comma I get a run-time erro
1004

Unable to get Find propert of WorksheetFunction class.

Any tips would be appreciated

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Using Worksheet Function Find in VBA

Try this

Sub test()
If ActiveCell.Value Like "*,*" Then MsgBox "Contains "","""
End Sub


bcmiller < wrote:

I am trying to use the worksheetfunction find to establish whether a
text string contains a comma or not (refer below)

testComma = WorksheetFunction.Find(",", ResultsValue, 1)

I have also tried

testComma = iserror(WorksheetFunction.Find(",", ResultsValue, 1))

However, if the string does not contain a comma I get a run-time error
1004

Unable to get Find propert of WorksheetFunction class.

Any tips would be appreciated.


---
Message posted from http://www.ExcelForum.com/


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Using Worksheet Function Find in VBA

Try

On Error Resume Next
testComma = WorksheetFunction.Find(",", ResultsValue, 1)
If testComma 0 Then
...
On Error Gotol 0

--

HTH

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

"bcmiller " wrote in message
...
I am trying to use the worksheetfunction find to establish whether a
text string contains a comma or not (refer below)

testComma = WorksheetFunction.Find(",", ResultsValue, 1)

I have also tried

testComma = iserror(WorksheetFunction.Find(",", ResultsValue, 1))

However, if the string does not contain a comma I get a run-time error
1004

Unable to get Find propert of WorksheetFunction class.

Any tips would be appreciated.


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Using Worksheet Function Find in VBA

if instr(ResultsValue,",") 0 then
msgbox ResultsValue & " contains a comma"
End if


Demo'd from the immediate window:

ResultsValue = "abcde,fghih"
? instr(ResultsValue,",")
6
ResultsValue = "abcdefghih"
? instr(ResultsValue,",")
0
--
Regards,
Tom Ogilvy

"bcmiller " wrote in message
...
I am trying to use the worksheetfunction find to establish whether a
text string contains a comma or not (refer below)

testComma = WorksheetFunction.Find(",", ResultsValue, 1)

I have also tried

testComma = iserror(WorksheetFunction.Find(",", ResultsValue, 1))

However, if the string does not contain a comma I get a run-time error
1004

Unable to get Find propert of WorksheetFunction class.

Any tips would be appreciated.


---
Message posted from http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using Worksheet Function Find in VBA

Thanks All.

I have used variations of each of your code samples for differen
purposes and they work a treat.

Cheers

b

--
Message posted from http://www.ExcelForum.com

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
Find text - worksheet function or macro? sebh007 Excel Discussion (Misc queries) 6 January 8th 07 12:53 AM
Find last non-blank row with a worksheet function Bruce Excel Worksheet Functions 2 November 25th 05 05:10 AM
Can the find/replace function be used for worksheet headers/footer wz7y2k Excel Worksheet Functions 0 March 21st 05 05:05 AM
Worksheet Function - Find? DAA Excel Worksheet Functions 2 February 24th 05 04:15 PM
for stats worksheet in XL how do i find the minitab function freethrow18 Excel Worksheet Functions 1 February 2nd 05 05:38 AM


All times are GMT +1. The time now is 08:07 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"