Count Words in VBA Regular Expression
===
## In VBA Moudle
``` vba
Function countWord(MyRange As Range) As Long
with createobject("vbscript.regexp")
.Global = True
.MultiLine = True
.IgnoreCase = False
.Pattern = "\S+"
countWord = .Execute(MyRange.value).count
End With
End Function
```
## In EXCEL
in cell A2, write `can have a variety ** of data`.
in cell B2, write `=countWord(A2)`.
cell B2 will display `7`.