• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User


  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Control variable already in use


New Member
hello I have this code but when I run the code I get error "control variable already in use" kindly help

>>> use code - tags <<<
Dim sh As Worksheet
Dim i As Long
Set sh = Sheets("SG_Sheet1")
For a = 1 To 6
Me.ListBox1.List(0, a - 1) = sh.Cells(1, a)
Next a
Me.ListBox1.Selected(0) = True

For i = 2 To sh.Range("A1000000").End(xlUp).Offset(1, 0).Row
For j = 1 To 6
H = Application.WorksheetFunction.CountIf(sh.Range("A" & 2, "F" & i), _
sh.Cells(i, f))
If H = 1 And LCase(sh.Cells(i, f)) = LCase(Me.TextBox1) Or H = 1 And _
sh.Cells(i, f) = Val(Me.TextBox1) Then
For x = 1 To 6
For x = 1 To 6
Me.ListBox1.List(ListBox1.ListCount - 1, x - 1) = sh.Cells(i, x)
Next x
End If
Next j
Next i
Last edited by a moderator:


Well-Known Member
When you get the error message, click on Debug and tell us which line of code is highlighted and tell us the complete error message.

I am guessing these lines are thee issue. Cannot have the For x line more than once and have only one Next x.

For x = 1 To 6
For x = 1 To 6