Count of Substrings

Excel Formula (Single Cell)
=IF(LEN(A2)=0,"",IF(A2="n/a","",REPT("1",LEN(A2)-LEN(SUBSTITUTE(A2,CHAR(10),))+1)))
Excel Formula (MS365)
=LET(a,A2:A6,r,"1",n,"n/a",d,CHAR(10),
IF(LEN(a)=0,"",IF(a=n,"",REPT(r,LEN(a)-LEN(SUBSTITUTE(a,d,))+1))))
VBA
Sub GenerateResponseIds()
' Define constants.
' Both
Const SHEET_NAME As String = "Sheet1"
' Source
Const S_TOP_CELL As String = "A2"
Const S_STRING_DELIMITER As String = vbLf
Const S_NA_STRING As String = "n/a"
' Destination
Const D_COLUMN As String = "B"
Const D_REPEAT_COUNT_STRING As String = "1"
' Clears the excessive rows when the data previously had more rows than now.
' If the number of rows will only grow, set it to 'False'.
Const D_OK_TO_CLEAR_COLUMN_TO_BOTTOM As Boolean = True
' Reference the workbook.
Dim wb As Workbook: Set wb = ThisWorkbook ' workbook containing this code
' If it's not, reference it by its name or use 'ActiveWorkbook' instead.
' Reference the worksheet.
Dim ws As Worksheet: Set ws = wb.Sheets(SHEET_NAME)
' Reference the single-column ranges and retrieve their number of rows.
Dim srg As Range, drg As Range, RowsCount As Long
With ws.Range(S_TOP_CELL)
RowsCount = ws.Cells(ws.Rows.Count, .Column).End(xlUp).Row - .Row + 1
If RowsCount < 1 Then Exit Sub ' no data
Set srg = .Resize(RowsCount)
Set drg = srg.EntireRow.Columns(D_COLUMN)
End With
' Return the source values in a 2D one-based (single-column) array.
Dim sData() As Variant
If RowsCount = 1 Then
ReDim sData(1 To 1, 1 To 1): sData(1, 1) = srg.Value
Else
sData = srg.Value
End If
' Define and populate the destination array applying the required logic.
Dim dData() As String: ReDim dData(1 To RowsCount, 1 To 1)
' If the ones should be numbers, as a simple fix,
' use 'Dim dData() As Variant' instead.
Dim SubStrings() As String, RowString As String
Dim Row As Long, SubStringsCount As Long
For Row = 1 To RowsCount
RowString = CStr(sData(Row, 1))
Select Case True
Case Len(RowString) = 0 ' is blank
' do nothing; corresponding cell will become empty
Case StrComp(RowString, S_NA_STRING, vbTextCompare) = 0 ' is NA
' do nothing; corresponding cell will become empty
' If 'n/a' was supposed to be the '#N/A' error, as a simple fix,
' use 'Case IsError(sData(Row, 1))' as the first case instead.
Case Else
' Return the substrings in a String array.
SubStrings = Split(RowString, S_STRING_DELIMITER)
' Retrieve the number of elements of the String array.
SubStringsCount = UBound(SubStrings) + 1
' Write the repeating string.
dData(Row, 1) = String(SubStringsCount, D_REPEAT_COUNT_STRING)
End Select
Next Row
' Optionally, clear the destination column.
If D_OK_TO_CLEAR_COLUMN_TO_BOTTOM Then
drg.Resize(ws.Rows.Count - drg.Row + 1).Clear
End If
' Populate the destination range.
drg.Value = dData
' Inform user.
MsgBox "Response IDs generated.", vbInformation
End Sub