Excel 寻找如何通过循环将用户输入放入我的代码中

Excel 寻找如何通过循环将用户输入放入我的代码中,excel,vba,Excel,Vba,这是我当前的代码,但我想添加用户对数据的输入,这些数据可能会从不同的行开始每周更改,并且会在不同的列中删除值。如何将其输入到当前代码中?鉴于您提供的代码,下面的代码段应该是最简单的方法。我已将myRow和myColumn的数据类型更改为Long,以便在输入时正确抛出错误 Sub Delete0() Dim myRow As Variant myRow = InputBox("What row does the data start in?") Dim myColumn As Variant m

这是我当前的代码,但我想添加用户对数据的输入,这些数据可能会从不同的行开始每周更改,并且会在不同的列中删除值。如何将其输入到当前代码中?

鉴于您提供的代码,下面的代码段应该是最简单的方法。我已将myRow和myColumn的数据类型更改为Long,以便在输入时正确抛出错误

Sub Delete0()
Dim myRow As Variant
myRow = InputBox("What row does the data start in?")

Dim myColumn As Variant
myColumn = InputBox("What Column does the data start in? (number format, i.e A=1, B=2)")

Dim LR As Long
Dim FR As Long

LR = 1 'where to have myRow be entered
FR = Cells(Rows.Count, 1).End(xlUp).Row

Do Until LR > FR
    If Cells(LR, 17).Value > 0 Then 'Where to have myColumn be entered
        LR = LR + 1
    Else
        Cells(LR, 17).EntireRow.Delete
        FR = FR - 1
    End If
Loop
End Sub
Sub Delete0()
Dim myRow As Long
myRow = InputBox("What row does the data start in?")

Dim myColumn As Long
myColumn = InputBox("What Column does the data start in? (number format, i.e A=1, B=2)")

Dim LR As Long
Dim FR As Long

LR = myRow 'where to have myRow be entered
FR = Cells(Rows.Count, 1).End(xlUp).Row

Do Until LR > FR
    If Cells(LR, myColumn).Value > 0 Then 'Where to have myColumn be entered
        LR = LR + 1
    Else
        Cells(LR, myColumn).EntireRow.Delete
        FR = FR - 1
    End If
Loop
End Sub