rogerlai
09-12-2012, 07:52 PM
Hi all,
I am a rookie in vba and wanna for loop sth on every line but the following code only loops in alternate lines. wt is wrong?
Private Sub loopingName()
Dim name As String, number As Integer, k As Integer
For k = 1 To 17000
If IsEmpty(Cells(k, 2).Value) Then
name = inputbox("please enter name", "looping")
number = inputbox("please enter number", "looping step 2")
For i = 1 To number
Cells(k + i - 1, 2).Value = name
i = i + 1
Next
End If
Next
End Sub
Thanks!
I am a rookie in vba and wanna for loop sth on every line but the following code only loops in alternate lines. wt is wrong?
Private Sub loopingName()
Dim name As String, number As Integer, k As Integer
For k = 1 To 17000
If IsEmpty(Cells(k, 2).Value) Then
name = inputbox("please enter name", "looping")
number = inputbox("please enter number", "looping step 2")
For i = 1 To number
Cells(k + i - 1, 2).Value = name
i = i + 1
Next
End If
Next
End Sub
Thanks!