我有:
当宏启动时,可能会选择任何给定行中的单个单元格,并且我希望在同一行中返回相应单元格的值,但返回列"Bit“中的相应单元格的值。
Excel具有如下所示的引用表单元格的功能
TableA[[#This Row], [Bit]]其中的“位”是一列,这将发挥完美的作用。但是,在VBA!中似乎不起作用--例如:
ActiveSheet.Range("TableA[[#This Row], [Bit]]").Select结果“运行时错误'1004':应用程序定义的或对象定义的错误”
或者,我认为像这样的事情可能会奏效:
ActiveSheet.Cells("TableA[Bit]", ActiveCell.Row).Select但是它也失败了,有“运行时错误13:类型不匹配”。
您知道通过引用想要的列标题/标题加上当前选定单元格的行来选择表格中单元格的另一种简单的方法吗?
谢谢你的帮助!
发布于 2014-01-22 13:24:40
尝尝这个
[TableA[@Bit]].Select或者这个
ActiveSheet.Cells(ActiveCell.Row, Range("TableA[Bit]").Column).Select发布于 2014-01-22 14:15:08
我想你需要这个..。
Sub TableA()
Dim oSh As Worksheet
Set oSh = ActiveSheet
With oSh.ListObjects("TableA")
'Select entire table
.Range.Select
'Select just the data of the entire table
.DataBodyRange.Select
'Select third column
.ListColumns(3).Range.Select
'Select only data of first column
.ListColumns(1).DataBodyRange.Select
'Select just row 4 (header row doesn't count!)
.ListRows(4).Range.Select
End With
End Subhttps://stackoverflow.com/questions/21283637
复制相似问题