[英]How to call a subroutine to multiple rows in a column in VBA
我正在開發一個項目,以開發功能來訓練具有一組文本評論的機器學習分類器。 我遇到問題的功能是計算評論中是否包含特定關鍵字“驚人”,然后根據是否找到關鍵字在評論旁邊的列中顯示 1 或 0。
主要問題是我的值不會顯示在列中。 這是我上過的唯一一門編碼/編程課程,而且我是初學者。
'this feature is used to find the keyword "amazing" in the reviews
Sub FindKeywordAmazing()
Dim cell As Range
Dim WordCount As Integer
Dim Line As Integer
Dim Count As Integer
WordCount = 0
Line = 2
Count = 0
'using an If statement to update the word count if the keyword amazing is present
For Each cell In Range("A2:A1001")
If InStr(cell.Value, "amazing") > 0 Then
WordCount = WordCount + 1
Else
WordCount = 0
End If
Count = WordCount
Range("C" & Line).Value = Count
Line = Line + 1
Next
'calling the sub with the value of the word count to the C column
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.