Link to home
Start Free TrialLog in
Avatar of touyets
touyets

asked on

Excel / VBA: my code won't stop counting

I have a problem,

I have a piece of code (attached code snippet) that won't stop when a reaches 5.

i can't seem to find a solution to this... I thought For a = b To 5 would solve this.

Regards.
For a = .UsedRange.Row To .UsedRange.Rows.Count
        If .Cells(a, 2) = "Not Done" Then
        Me.Controls("AdminTitleC" & b) = .Cells(a, 6)
        Me.Controls("AdminCompanyC" & b) = .Cells(a, 8)
        Me.Controls("Locationp" & b) = .Cells(a, 7)
        Me.Controls("authorp" & b) = .Cells(a, 4)
        Me.Controls("consp" & b) = .Cells(a, 5)
        b = b + 1
        End If
    Next a
    For a = b To 5
        Me.Controls("AdminImageC" & a).Visible = False
        Me.Controls("AdminTitleC" & a).Visible = False
        Me.Controls("AdminCompanyC" & a).Visible = False
        Me.Controls("Locationp" & a).Visible = False
        Me.Controls("authorp" & a).Visible = False
        Me.Controls("consp" & a).Visible = False
    Next a

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of touyets
touyets

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of touyets
touyets

ASKER

Close please.