繁体   English   中英

使此代码循环直到最后一个非空行

[英]Make this code loop until the last non empty row

我为合并循环所做的一切都破坏了代码。
我尝试使用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
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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM