美好的一天!在我的工作表中我有(1) textbox as TextBox1
和1 button for submit button.
我在這裏給出了分割文本作爲輸出的示例代碼。我只是希望如果textbox1中有重複的單詞,並且用戶輸入提交按鈕,它將保存到工作表(DatabaseStorage)和categorize the output
從No Duplicated Word
和duplicated Word
。因爲系統的某些功能需要這兩個不同的字段。數組插入重複的和不重複的數據到VBA中的不同列
Private Sub CommandButton1_Click()
Call SplitText
End Sub
Sub SplitText()
Dim WArray As Variant
Dim TextString As String
TextString = TextBox1
WArray = Split(TextBox1, " ")
If (TextString = "") Then
MsgBox ("Error: Pls Enter your data")
Else
With Sheets("DatabaseStorage")
.Cells(.Rows.Count, 1).End(xlUp).Offset(1, 0).Resize(UBound(WArray) + IIf(LBound(WArray) = 0, 1, 0)) = Application.Transpose(WArray)
End With
MsgBox ("Successfully inserted")
End If
End Sub
你可以提供更多關於如何在文本框中輸入數據的信息嗎?盒子裏每行有一個單詞嗎? – kschindl
嗨,先生,我已經更新後檢查新圖像,你的答案是我需要的,但有一個意想不到的輸出列「沒有重複的單詞」我想單詞財務和刪除重複單詞財務的另一個詞。像上面的例子sir –