![](/img/trans.png)
[英]VBA with multiple discounts & Problem of next without for & insert value in respective cell
[英]insert value to next cell using vba
我正在嘗試從網頁獲取數據。 我的VBA代碼如下
m = 0
For Each htmlele1 In doc.getElementsByClassName("resultsbranch")
m = m + 1
companyname = htmlele1.getElementsByTagName("h2")
Address = htmlele1.getElementsByTagName("span")
If Address.getAttribute("itemprop") = "myaddress" Then
Range("D" & i).Value = companyname.innerText + "," + Address.innerText
End If
Teliphone = htmlele1.getElementsByClassName("teldata")
If Teliphone.getAttribute("itemprop") = "tel" Then
Range("E" & i).Value = Teliphone.innerText
End If
'i = i + 1
'Debug.Print i
Next
在第一次迭代中,將值插入到D,E列中
在第二次迭代中,我想將數據插入F,H 。
在第3次迭代I,J
在第4次迭代中, K,L直到第n次迭代
我怎樣才能做到這一點 ?
代替:
Range("D" & i).Value
Range("E" & i).Value
采用:
Cells(i, (m*2 + 3)).Value
Cells(i, (m*2 + 4)).Value
或使用其他櫃台...您喜歡...希望有幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.