variable replacement

In the code below I attempted to replace the fact that it 'looks' for a value in a cell with an input box that requests the value and all I got was an error message.

 'xRun = Range("I1") replaced with

Let xRun = Application.InputBox("Mx Number of 'combinations' ", Type:=1)


I'd appreciate it if someone can properly edit the code so that it works as intended.



Sub Drop_Runs()
Dim i         As Long
Dim j         As Long
Dim xLast_Row As Long
Dim xResponse As Long
Dim xRun      As Long
Dim xWork     As Long
Dim xArray    As Variant

    'xRun = Range("I1")
Let xRun = Application.InputBox("Mx Number of 'combinations' ", Type:=1)

If xRun < 1 Or xRun > 3 Then
    MsgBox ("Invalid ""Run"" (" & xRun & ") - run cancelled.")
    Exit Sub
End If

xLast_Row = ActiveSheet.UsedRange.Cells(1, 1).Row + ActiveSheet.UsedRange.Rows.Count - 1
If xLast_Row < 18 Then
    MsgBox ("No data found - run cancelled.")
    Exit Sub
End If

xResponse = MsgBox("About to delete rows with runs > " & xRun & "." _
                & Chr(10) & Chr(10) & "('OK' to confirm, 'Cancel' to go into Debug.)", vbOKCancel, "Drop Runs")
If xResponse = 2 Then
    MsgBox ("Used cancelled run.")
    Exit Sub
End If

Debug.Print Now()
Application.ScreenUpdating = False

    xArray = Range("B1:F" & xLast_Row)
    
    For i = xLast_Row To 18 Step -1
        xWork = 0
        For j = 2 To 5
            If xArray(i, j) = xArray(i, j - 1) + 1 Then xWork = xWork + 1
        Next
        If xWork > xRun Then xArray(i, 1) = "XX DELETE XX" 'Cells(i, 1).EntireRow.Delete
    Next

Range("B1:F" & xLast_Row) = xArray

Application.ScreenUpdating = True
Debug.Print Now()

MsgBox ("Run complete.")

End Sub

Open in new window

Pedrov664Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RobSampsonCommented:
If you remove the word "Let", does that run as intended?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Pedrov664Author Commented:
seems to run. Let me try it on a few more to confirm. What difference does taking out that word make? Could it be that simple?
0
RobSampsonCommented:
I think it's basically a deprecated term:
http://msdn.microsoft.com/en-us/library/aa243390(v=vs.60).aspx

It's not required for variable assignment.

Rob.
0
Pedrov664Author Commented:
Excellent
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.