shahin Active Member Jul 21, 2017 #2 Put words in column A between 1 to 5 cell and get results adjacent to it. Code: Sub count_length() Dim x As Long For x = 1 To 5 Cells(x, 2) = Len(Cells(x, 1)) Next x End Sub
Put words in column A between 1 to 5 cell and get results adjacent to it. Code: Sub count_length() Dim x As Long For x = 1 To 5 Cells(x, 2) = Len(Cells(x, 1)) Next x End Sub
Hui Excel Ninja Staff member Jul 21, 2017 #3 I would use a Function such as: Code: Function CountWords(word) As Integer CountWords = Len(word) - Len(Replace(word, " ", "")) + 1 End Function then in Excel =CountWords(A2) or in VBA NoWords = CountWords(word)
I would use a Function such as: Code: Function CountWords(word) As Integer CountWords = Len(word) - Len(Replace(word, " ", "")) + 1 End Function then in Excel =CountWords(A2) or in VBA NoWords = CountWords(word)