Excel中的macros超链接
我有这个代码,将单元格更改为超链接。 我想要使用超链接中的单元格的值
Sub HyperAdd() 'Converts each text hyperlink selected into a working hyperlink For Each xCell In Selection ActiveSheet.Hyperlinks.Add Anchor:=xCell, _ Address:="http://example.ie/booking/viewBooking/=xCell" Next xCell End Sub
如果单元格的值是123,我如何使锚链接这个urlhttp://example.ie/booking/viewBooking/123
正如Fadi所指出的那样,这个问题的答案是语法修正。
更改:
Address:="http://example.ie/booking/viewBooking/=xCell"
成为:
Address:="http://example.ie/booking/viewBooking/" & xCell
Excel将引号内的字符视为string,因此在“http …”string中完全引用“xCell”不起作用。 每次只会导致地址为“ http://example.ie/booking/viewBooking/=xCell
”,因为Excel不会将string中的variables名称视为variables。
相反,string需要如上所示添加,以便在string外部使用xCell,并使用xCell的值而不是文本“xCell”。
那么,如果xCell的值是“abc123”,那么
Address:="http://example.ie/booking/viewBooking/" & xCell
将会:
Address:="http://example.ie/booking/viewBooking/" & "abc123"
这变成:
Address:="http://example.ie/booking/viewBooking/abc123"
- 打开Excel文件时Pandas IndexError
- 如何从VBA Excel中更改PC的MAC地址
- 使用vlookup时,对象'_Global'的方法'范围'失败错误
- 为什么相同的数据需要更多的文本文件空间,然后Excel文件?
- 有人可以提供代码/逻辑来检索excel(.xlsx)数据,比如“”driver.findElement(By.id(“”))。sendkeys(getExceldata(row,column));“
- 如何使用多个标准来计算表中值的唯一出现次数?
- InnoDB表错误:不存在/存在。 孤儿桌? mysql命令客户端中的不可见数据库
- Asp.Net(c#) – 读取Excel工作表
- 我怎么能插入一个数据框在Excel中使用xlwings没有pywintypes.com_error?