I have a very specific question
我有一个非常具体的问题
There is a native vba function that counts how many time a text (such as a word or even a single character) repeats inside other text (string)?
有一个本机vba函数可以计算文本(例如单词甚至单个字符)在其他文本(字符串)中重复的次数?
It would get as parameters two string values, for example, and return a integer/long value.
例如,它将获取两个字符串值作为参数,并返回整数/长值。
I looked among worksheet functions and I couldn't find any. Should I make my own one?
我看了工作表函数,我找不到任何。我应该自己做一个吗?
Thanks very much!
非常感谢!
1 个解决方案
#1
0
As it doesn't exist in vba, you should make your own. You can write a loop using InStr, counting the number of iterations. It should be pretty performant as it essentially won't have to do any memory allocations, and VBA's string functions are fast.
因为在vba中不存在,所以你应该自己制作。您可以使用InStr编写循环,计算迭代次数。它应该是非常高效的,因为它本质上不需要进行任何内存分配,并且VBA的字符串函数很快。
#1
0
As it doesn't exist in vba, you should make your own. You can write a loop using InStr, counting the number of iterations. It should be pretty performant as it essentially won't have to do any memory allocations, and VBA's string functions are fast.
因为在vba中不存在,所以你应该自己制作。您可以使用InStr编写循环,计算迭代次数。它应该是非常高效的,因为它本质上不需要进行任何内存分配,并且VBA的字符串函数很快。