我有一个电子表格,其中包含单元格 A 到 G 中的值。
我需要读取单元格 F 中的数据,并根据数据,在 H 列中的相应单元格中制定一个超链接,并将来自单元格 G(F 旁边)的数据插入超链接中。
EG 1
单元格 F 包含:DPD
单元格 g 包含:123456
希望单元格 H 创建超链接:
=HYPERLINK(" http://www.dpd.co.uk/tracking/quicktrack.do?search.consignmentNumber= "&CELLG*&"&search.searchType=16&search.javascriptValidated=0&appmode=guest")
EG 2
单元格 F 包含:TNT
单元格 g 包含:abcde
希望单元格 H 创建超链接:
=HYPERLINK(" http://www.tnt.com/express/en_gb/site/searchresults.html?q=CELLG " )
我在单元格 F 中有更多其他值,它们依赖于不同的超链接公式,但我应该能够重复和更改代码以适应这些值。
更新:
这是我目前应用该公式的尝试。
Range("I1").Select
ActiveCell.FormulaR1C1 = _
"=IF(RC[-2]=""dpd"",HYPERLINK(""http://www.dpd.co.uk/tracking/quicktrack.do?search.consignmentNumber=""&RC[-1]&""&search.searchType=16&search.javascriptValidated=0&appmode=guest""))"
Range("I1").Select
Selection.AutoFill Destination:=Range("i1:i" & Range("A" & Rows.Count).End(xlUp).Row), Type:=xlFillCopy
Range("I2").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A1:I1").Select
ActiveSheet.Range("A1:i1").AutoFilter Field:=9, Criteria1:="FALSE"
Range("I2").Select
ActiveCell.FormulaR1C1 = _
"=IF(R[-1]C[-2]=""City Link"",HYPERLINK(""http://www.packagetrackr.com/track/citylink/""&R[-1]C[-1]&""""))"
Range("I2").Select
Selection.AutoFill Destination:=Range("i2:i" & Range("A" & Rows.Count).End(xlUp).Row), Type:=xlFillCopy
Range("A1:I1").Select
ActiveSheet.Range("A1:i1").AutoFilter Field:=9, Criteria1:="FALSE"
Range("i2").Select
ActiveCell.FormulaR1C1 = _
"=IF(R[-1]C[-2]=""hermes"",HYPERLINK(""http://www.hermes-europe.co.uk/tracker.html?trackingNumber=""&R[-1]C[-1]&""&Postcode=""&R[-1]C[-4]&R[-1]C[-3]&""""))"
Range("I2").Select
Selection.AutoFill Destination:=Range("i2:i" & Range("A" & Rows.Count).End(xlUp).Row), Type:=xlFillCopy
If ActiveSheet.AutoFilterMode = True Then ActiveSheet.AutoFilterMode = False
Range("I2").Select
Selection.Delete Shift:=xlUp
Range("I1").Select
我无法弄清楚如何在过滤列表上自动填充。
也许我需要尝试循环方法?
失败的公式:
=IF(G2="hermes",HYPERLINK("www.hermes-europe.co.uk/tracker.html?trackingNumber="&H2&"&Postcode="&e2&f2&"),IF(G2="Parcelforce",HYPERLINK("www .parcelforce.com/track-trace?trackNumber="&h2&"),IF(G2="Royal Mail",HYPERLINK("www.royalmail.com/track-trace?track=track&trackNumber="&h2&"&gear=track&imageRootPath=&loc =en_GB&default=default&emt=emt"),IF(G2="Yodel",HYPERLINK("www.myyodel.co.uk/tracking?parcel_id="&h2&"&postcode="&e2&"%23"&f2&"),IF(G2 ="4 Square",HYPERLINK("login.smartconsign.co.uk/trackingcust.aspx?partnerid=EAFSQ001&jobno="&h2&"),IF(G2="Deutsche Post",HYPERLINK("nolp.dhl.de/nextt-online-public/set_identcodes.do?lang=en&idc="&h2&"&rfn=&extendedSearch=true"),IF(g2="No Tracking","&h2&")"""))))