Excel 用循环功能替换输入框

Excel 用循环功能替换输入框,excel,vba,Excel,Vba,所以我想创建一个循环函数-其中 如果O列中的响应为“是”,则在C列中输入值,作为复制工作表的“新名称” 循环,直到列O为空 我知道我必须删除输入框(“为复制的工作表输入名称”) 但是,我不确定在newname之后加什么作为循环函数 Sub Button112_Click() Dim newName As String On Error Resume Next newName = InputBox("Enter the name for the copied worksheet") If ne

所以我想创建一个循环函数-其中
如果O列中的响应为“是”,则在C列中输入值,作为复制工作表的“新名称” 循环,直到列O为空

我知道我必须删除输入框(“为复制的工作表输入名称”)
但是,我不确定在newname之后加什么作为循环函数

Sub Button112_Click()

Dim newName As String

On Error Resume Next
newName = InputBox("Enter the name for the copied worksheet")
If newName <> "" Then


    ThisWorkbook.Sheets("Template").Copy After:=Worksheets(Sheets.Count)
    On Error Resume Next
    ActiveSheet.Name = newName
    Range("$D$3").Value = newName
End If

Dim n As Name
For Each n In ActiveWorkbook.Names
n.Visible = True
Next n

Dim numrow
numrow = Range("F16").Value

If IsNumeric(numrow) Then

For i = 1 To numrow

Call INRW

Next i
End If

End Sub

我猜你是在追求这样的东西:

Sub Button112_Click()

    Dim lastRow As Long, i As Long

    With Worksheets("mySheetName")'change mySheetName to suit your needs

        lastRow = .Cells(Rows.Count, 15).End(xlUp).Row
        For i = 1 To lastRow
            If .Cells(i, 15).Value2 = "Yes" Then
                ThisWorkbook.Sheets("Template").Copy After:=Worksheets(Sheets.Count)
                ActiveSheet.Name = .Cells(i, 3).Value2
                Range("$D$3").Value = .Cells(i, 3).Value2
            End If
        Next

    End With

    .... 
    rest of your code

不清楚你发布的代码与你的问题有何关联。
Sub Button112_Click()

    Dim lastRow As Long, i As Long

    With Worksheets("mySheetName")'change mySheetName to suit your needs

        lastRow = .Cells(Rows.Count, 15).End(xlUp).Row
        For i = 1 To lastRow
            If .Cells(i, 15).Value2 = "Yes" Then
                ThisWorkbook.Sheets("Template").Copy After:=Worksheets(Sheets.Count)
                ActiveSheet.Name = .Cells(i, 3).Value2
                Range("$D$3").Value = .Cells(i, 3).Value2
            End If
        Next

    End With

    .... 
    rest of your code