Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 1782|回复: 6

[已解决]请大侠帮我看看这段录入代码为什么不起效

[复制链接]
发表于 2013-6-5 19:32 | 显示全部楼层 |阅读模式
我想在第一页资料页录入,在第2页生成资料,为什么运行后,既不报错,也没结果,第2页什么内容都没填进去
最佳答案
2013-6-6 10:31
r = Sheets("资料页").Range("b65535").End(xlUp).Row + 1



{:041:}

资料录入.rar

10.42 KB, 下载次数: 15

excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2013-6-5 19:43 | 显示全部楼层
没看到代码
2007及以上版本,如有宏代码,需要保存成 XLSM 类型
回复

使用道具 举报

发表于 2013-6-5 19:47 | 显示全部楼层
哪有什么代码呀,找了半天没找到
回复

使用道具 举报

发表于 2013-6-5 21:01 | 显示全部楼层
本帖最后由 ligh1298 于 2013-6-5 21:10 编辑

楼主:是不是想要这样的?见附件!刚才传错了附件。

录入资料保存.rar

11.72 KB, 下载次数: 26

回复

使用道具 举报

 楼主| 发表于 2013-6-6 09:59 | 显示全部楼层
这是我的代码

Sub 资料生成()
Dim a(20) As String, i As Long, j As Long
With Sheets("填写页")
a(1) = .Cells(10, 4)
a(2) = .Cells(2, 4)
a(3) = .Cells(3, 4)
a(4) = .Cells(4, 4)
a(5) = .Cells(8, 4)
a(6) = .Cells(5, 4)
a(7) = .Cells(6, 4)
a(8) = .Cells(7, 4)
a(9) = .Cells(10, 4)
a(10) = .Cells(11, 4)
a(11) = .Cells(12, 4)
a(12) = .Cells(12, 5)
a(13) = .Cells(12, 6)
a(14) = .Cells(13, 4) & "," & .Cells(13, 5) & "," & .Cells(13, 6)
a(15) = .Cells(14, 4) & "," & .Cells(14, 5) & "," & .Cells(14, 6)
a(16) = .Cells(15, 4) & "," & .Cells(15, 5) & "," & .Cells(15, 6)
a(17) = .Cells(16, 4) & "," & .Cells(16, 5) & "," & .Cells(16, 6)
a(18) = .Cells(17, 4) & "," & .Cells(17, 5) & "," & .Cells(17, 6)
a(19) = .Cells(18, 4)
a(20) = .Cells(19, 4)
End With
r = Sheets("资料页").Range("b65535").End(xlUp).Row

If r > 6 Then
  For i = 7 To r
  If Sheets("资料页").Cells(i, 4) = Sheets("填写页").Cells(2, 4) Then
  y = MsgBox("已有同名存在,是否添加?", 4)
   If y = 6 Then GoTo 100
  Exit Sub
  End If
  Next i
End If
100:
Sheets("资料页").Cells(r + 1, 2) = r - 6
For j = 3 To 21
Sheets("资料页").Cells(r + 1, j) = a(j - 1)
Next j
End Sub
回复

使用道具 举报

发表于 2013-6-6 10:31 | 显示全部楼层    本楼为最佳答案   
r = Sheets("资料页").Range("b65535").End(xlUp).Row + 1



{:041:}
回复

使用道具 举报

 楼主| 发表于 2013-6-6 10:46 | 显示全部楼层
啊,谢谢,确实漏掉了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-4-18 10:23 , Processed in 0.322931 second(s), 11 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表