- UID
- 242175
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2005-4-12
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
Public Sub 对比复制()
Dim n As Integer
Dim i As Integer
Dim j As Integer
Dim u As Integer
Dim m As Integer
Dim k As String
Dim l As String
Dim o As Integer
Dim p As Integer
X1 = "请输入表2行数"
u = InputBox(X1)
X2 = "请输入表1行数"
m = InputBox(X2)
X3 = "请输入表1名称"
k = InputBox(X3)
X4 = "请输入表2名称"
l = InputBox(X4)
X5 = "请输入表1列数"
o = InputBox(X5)
X6 = "请输入表2列数"
p = InputBox(X6)
For i = 1 To u
For j = 1 To m
If Sheets("l").Cells(i, 1) = Sheets("k").Cells(j, 1) Then
Sheets("l").Select
Cells(i, p).Select
Selection.Copy
Sheets("k").Select
Cells(j, o).Select
ActiveSheet.Paste
End If
Next j
Next i
End Sub
--------------------------------------------------------------
执行到If Sheets("l").Cells(i, 1) = Sheets("k").Cells(j, 1) Then就出问题了
提示错误9 下标越界
会VBA的兄弟帮忙解决一下,谢谢! |
|