0

How can I specify that with each For/next cycle, the number of the textbox should increase by one, from Userform1.Textbox1 to Userform1.Textbox2 and so on for each sheet in the workbook?

I am trying "UserForm1.TextBox & i" and "i = i + 1" But I get a syntax error.

Any advice?

Application.ScreenUpdating = False
SheetName = ActiveSheet.Name
FindString = InputBox("Enter the case number to search for:")

i = 1

For Each ws In Worksheets
    If ws.Name Like "lang*" Then
        With ws

            If Trim(FindString) <> "" Then
                With Sheets(1).Range("A:A")
                    Set Rng = .Find(What:=FindString, _
                                    After:=.Cells(.Cells.Count), _
                                    LookIn:=xlValues, _
                                    LookAt:=xlWhole, _
                                    SearchOrder:=xlByRows, _
                                    SearchDirection:=xlNext, _
                                    MatchCase:=False)
                    If Not Rng Is Nothing Then

            UserForm1.TextBox & i = ActiveSheet.Name & "     " & _
            Rng.Offset(0, 2).Value & "     " & _

            i = i + 1

                    Else: GoTo NotFound
                    End If
                End With
            End If

        End With
    End If
Next ws

Sheets(SheetName).Activate
Application.ScreenUpdating = True
UserForm1.Show
4

2 回答 2

1
UserForm1.Controls("TextBox" & i)
于 2013-08-22T18:16:32.877 回答
-1
var control = this.Controls.Find("TextBox" + i, true).FirstOrDefault();

if (control != null)
{
    //do something                
}
于 2013-08-22T18:35:01.727 回答