LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Count occurences of string in cell

I'm trying to count the number of times a sequence of characters occurs in a
cell. The sequence could be surrounded by non-printing characters, and/or
could appear more that once in one string (ABCblahABC SDF ABC blah).

I tried the following, but it seems to "miss" sometimes. Any reason why?

Thanks in advance!

Sub getNum()
Dim i As Long
Dim str As String

For i = 2 To Cells(Rows.Count, "a").End(xlUp).Row
str = InStr(Cells(i, 1), "ABC")
Cells(i, "B") = str
Next i

End Sub

 
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
Count occurences in string Ken Excel Discussion (Misc queries) 3 June 10th 09 08:29 PM
Count occurences of a letter in a cell Jair Batista Excel Worksheet Functions 2 January 8th 09 02:51 PM
Add string occurences ofey Excel Programming 2 May 30th 05 06:35 PM
How to Count String occurences Chaplain Doug Excel Programming 4 March 22nd 05 07:14 PM
count number of occurences within a string Gabriel Excel Worksheet Functions 2 November 25th 04 04:17 PM


All times are GMT +1. The time now is 03:27 AM.

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"