求救!!!!!!!!!!!!!!!!!!!!!!!!!!!1

zhaokeke2004 2005-02-16 12:47:35
已经知道单元格的地址,如"$A$1',我想取到同一行临近列("$B$1")的值,
在EXCEL里的宏里怎么写?
...全文
85 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
biruo1128 2005-02-18
  • 打赏
  • 举报
回复
楼上的只能用于OFFICE公式,不能用于宏,在宏中,在取单元格地址时,不要用object.address,用object.row和object.column,就可以知道行和列了,再用row+1,或者column+1就行了!
cqlxm 2005-02-17
  • 打赏
  • 举报
回复
还是贴给你吧:
Offset 属性 (Range 对象)
返回一个 Range 对象,该对象代表某个指定区域以外的区域。只读。

expression.Offset(RowOffset, ColumnOffset)
expression 必需。该表达式返回一个 Range 对象。

RowOffset Variant 类型,可选。该区域将偏移的行数(正值、负值或 0(零))。正值表示向下偏移,负值表示向上偏移,默认值为 0。

ColumnOffset Variant 类型,可选。该区域将偏移的列数(正值、负值或 0(零))。正值表示向右偏移,负值表示向左,默认值为 0。

示例
本示例激活 Sheet1 上活动单元格向右偏移三列、向下偏移三行处的单元格。

Worksheets("Sheet1").Activate
ActiveCell.Offset(rowOffset:=3, columnOffset:=3).Activate

本示例假设 Sheet1 中包含一个具有标题行的表格。本示例先选定该表格,但并不选择行首。运行本示例之前,活动单元格必须位于表格中。

Set tbl = ActiveCell.CurrentRegion
tbl.Offset(1, 0).Resize(tbl.Rows.Count - 1, _
tbl.Columns.Count).Select

cqlxm 2005-02-17
  • 打赏
  • 举报
回复
使用offset,具体的自己去查office的帮助
zhaokeke2004 2005-02-16
  • 打赏
  • 举报
回复
有没有简单一点的方法阿?
txin2004 2005-02-16
  • 打赏
  • 举报
回复
我用的笨办法,转换成直角坐标了。
肯定有更好的

Dim Int_rowidx As Integer
Dim Int_colomnidx As Integer

Call Find_Address(singleCell.Address(ReferenceStyle:=xlR1C1), Int_rowidx, Int_colomnidx)

。。。。

Sub Find_Address(ByVal cell_address As String, ByRef int_Rowindex As Integer, ByRef int_Colindex As Integer)

Select Case Len(cell_address)

Case 4
int_Rowindex = Mid(cell_address, 2, 1)
int_Colindex = Mid(cell_address, 4, 1)
Case 5
If Mid(cell_address, 3, 1) = "C" Then
int_Rowindex = Mid(cell_address, 2, 1)
int_Colindex = Mid(cell_address, 4, 2)
ElseIf Mid(cell_address, 4, 1) = "C" Then
int_Rowindex = Mid(cell_address, 2, 2)
int_Colindex = Mid(cell_address, 5, 1)
End If

Case 6
If Mid(cell_address, 3, 1) = "C" Then
int_Rowindex = Mid(cell_address, 2, 1)
int_Colindex = Mid(cell_address, 4, 3)
ElseIf Mid(cell_address, 4, 1) = "C" Then
int_Rowindex = Mid(cell_address, 2, 2)
int_Colindex = Mid(cell_address, 5, 2)
ElseIf Mid(cell_address, 5, 1) = "C" Then
int_Rowindex = Mid(cell_address, 2, 3)
int_Colindex = Mid(cell_address, 6, 1)
End If

End Select
End Sub

5,139

社区成员

发帖
与我相关
我的任务
社区描述
其他开发语言 Office开发/ VBA
社区管理员
  • Office开发/ VBA社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧