我做的所有事情都包含了一个循环破坏了代码
我尝试在迭代行中使用For Loop
,但它在userid
行上出错。我只需要做20次,共20行。
Sub Testbitly()
Dim userid As String
Dim apiKey As String
Dim shortURL As String
Dim URLcompleto As String
userid = Sheets("Plan1").Cells(7, 6)
apiKey = Sheets("Plan1").Cells(7, 7)
URLcompleto = Sheets("Plan1").Cells(7, 8)
shortURL = ShortenURL(userid, apiKey, _
URLcompleto, bitly)
Range("I7").Select
ActiveCell.FormulaR1C1 = shortURL
End Sub
答案 0 :(得分:1)
Sub Testbitly()
Dim userid As String
Dim apiKey As String
Dim shortURL As String
Dim URLcompleto As String
Dim LastRow As Long
LastRow = Sheets("Plan1").Cells(.Rows.Count, "F").End(xlUp).Row
For i = 7 To LastRow
userid = Sheets("Plan1").Cells(i, 6)
apiKey = Sheets("Plan1").Cells(i, 7)
URLcompleto = Sheets("Plan1").Cells(i, 8)
shortURL = ShortenURL(userid, apiKey, _
URLcompleto, bitly)
Sheets("Plan1").Cells(i, 9).FormulaR1C1 = shortURL
Next i
End Sub