ABCDEFGHIJKLMNOPQRSTUVWXY
1
2
3
4
5
567
...integer value to match (need to modify the regexp if you want to match text)
6
7
Number of occurrences in all sheet names:
1
=OccurrencesInSheetNames(TEXT(C5,0))
8
9
10
11
12
Place the code below in Tools > Script Editor, then save.
13
14
function OccurrencesInSheetNames(str) {
15
var c = 0;
16
var regExp = new RegExp('[' + str + ']', 'g');
17
var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();
18
var sheetnames = [];
19
for (var i=0; i<sheets.length; i++) {
20
sheetnames.push([sheets[i].getName()]);
21
}
22
for (var i=0; i<sheetnames.length; i++) {
23
var name = sheetnames[i].toString();
24
var count = (name.match(regExp) || []).length;
25
c += count;
26
}
27
return c;
28
}
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100