1
我想用一個用戶表單替換一個msgbox,但是當我顯示用戶表單時,它沒有像在msgbox中那樣的文本框中的數據,是否需要向文本框添加一些代碼?這裏是我所做的vba用用戶表單替換msgbox
Sub unknown()
Dim iListCount As Integer
Dim iCtr As Integer
' Turn off screen updating to speed up macro.
Application.ScreenUpdating = False
' Get count of records to search through (list that will be deleted).
iListCount = Sheets("sheet2").Cells(Rows.Count, "A").End(xlUp).Row
' Loop through the "master" list.
For Each x In Sheets("Sheet1").Range("A1:A" & Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row)
' Loop through all records in the second list.
For iCtr = iListCount To 1 Step -1
' Do comparison of next record.
' To specify a different column, change 1 to the column number.
If x.Value = Sheets("Sheet2").Cells(iCtr, 1).Value Then
' If match is true then delete row.
Sheets("Sheet2").Cells(iCtr, 1).EntireRow.Delete
End If
Next iCtr
Next
Application.ScreenUpdating = True
If Application.WorksheetFunction.CountA(Range("A:A")) = 0 Then
Exit Sub
End If
For Each r In Intersect(Range("A:A"), ActiveSheet.UsedRange)
If r.Value > "" Then
msg = msg & vbCrLf & r.Value
End If
Next r
' this msgbox works ok
'MsgBox msg, vbOKOnly, "Unknown servers"
frmunknownservers.Show
Textunknownservers.Text = msg
End Sub