这是唯一可行的方法,但我觉得这很丑陋。
有没有一种方法可以改进这一点,比如创建一个函数式FOR?或者这是处理这些字符串的最佳方法?
i.Navigate "https://inara.cz/elite/cmdr/42411/"
Do While i.Busy Or i.ReadyState <> READYSTATE_COMPLETE
Loop
Dim rank_combat, rank_trade, rank_explorer, rank_merc, rank_exo, rank_cqc As Variant
lin_B = Range("B65000").End(xlUp).Row + 3
rank_combat = idoc.getElementsByClassName("rankvalue").Item(0).innerText
rank_trade = idoc.getElementsByClassName("rankvalue").Item(1).innerText
rank_explorer = idoc.getElementsByClassName("rankvalue").Item(2).innerText
rank_merc = idoc.getElementsByClassName("rankvalue").Item(3).innerText
rank_exo = idoc.getElementsByClassName("rankvalue").Item(4).innerText
rank_cqc = idoc.getElementsByClassName("rankvalue").Item(5).innerText
clip.SetText "" & rank_combat & ""
clip.PutInClipboard
Range("B" & lin_B).Value = "Combat"
Range("C" & lin_B).Select
ActiveSheet.PasteSpecial Format:="Texto unicode", link:=False, _
DisplayAsIcon:=False, NoHTMLFormatting:=True
clip.SetText "" & rank_trade & ""
clip.PutInClipboard
Range("B" & lin_B + 1).Value = "Trade"
Range("C" & lin_B + 1).Select
ActiveSheet.PasteSpecial Format:="Texto unicode", link:=False, _
DisplayAsIcon:=False, NoHTMLFormatting:=True
clip.SetText "" & rank_explorer & ""
clip.PutInClipboard
Range("B" & lin_B + 2).Value = "Explorer"
Range("C" & lin_B + 2).Select
ActiveSheet.PasteSpecial Format:="Texto unicode", link:=False, _
DisplayAsIcon:=False, NoHTMLFormatting:=True
clip.SetText "" & rank_merc & ""
clip.PutInClipboard
Range("B" & lin_B + 3).Value = "Mercenary"
Range("C" & lin_B + 3).Select
ActiveSheet.PasteSpecial Format:="Texto unicode", link:=False, _
DisplayAsIcon:=False, NoHTMLFormatting:=True
clip.SetText "" & rank_exo & ""
clip.PutInClipboard
Range("B" & lin_B + 4).Value = "Exobiology"
Range("C" & lin_B + 4).Select
ActiveSheet.PasteSpecial Format:="Texto unicode", link:=False, _
DisplayAsIcon:=False, NoHTMLFormatting:=True
代码进入网站inara cz获取一些类并复制到剪贴板并粘贴在excel中的一些行。
2条答案
按热度按时间iszxjhcz1#
这里有一个方法可以清理它:
nwlqm0z12#
tnx @Tim威廉姆斯我还根据您的代码成功创建了另一个漂亮的形状,非常感谢