ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 效率神器,一键搞定繁琐工作
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
让更多数据处理,一键完成 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
查看: 845|回复: 2

求各位大神指点

[复制链接]

TA的精华主题

TA的得分主题

发表于 2013-11-8 11:30 | 显示全部楼层 |阅读模式
Public Function stockread(e())
Worksheets("数据输入").Select
Set readsheet1 = Sheets("数据输入")
e(1) = readsheet1.Range("k7").Value
e(2) = readsheet1.Range("e8").Value
e(3) = readsheet1.Range("e10").Value
e(4) = readsheet1.Range("e11").Value
e(5) = readsheet1.Range("e12").Value
e(6) = readsheet1.Range("e13").Value
e(7) = readsheet1.Range("e14").Value
e(8) = readsheet1.Range("e15").Value
e(9) = readsheet1.Range("e16").Value
e(10) = readsheet1.Range("e17").Value
e(11) = readsheet1.Range("e18").Value
e(12) = readsheet1.Range("h8").Value
e(13) = readsheet1.Range("h9").Value
e(14) = readsheet1.Range("h10").Value
e(15) = readsheet1.Range("h11").Value
e(16) = readsheet1.Range("h13").Value
e(17) = readsheet1.Range("h14").Value
e(18) = readsheet1.Range("h15").Value
e(19) = readsheet1.Range("h17").Value
e(20) = readsheet1.Range("h18").Value
e(21) = readsheet1.Range("k8").Value
e(22) = readsheet1.Range("k9").Value
e(23) = readsheet1.Range("k10").Value
e(24) = readsheet1.Range("k12").Value
e(25) = readsheet1.Range("k13").Value
e(26) = readsheet1.Range("k14").Value
e(27) = readsheet1.Range("k15").Value
e(28) = readsheet1.Range("k17").Value
e(29) = readsheet1.Range("k18").Value
End Function
Public Function selectfreecol(f)
Set readSheet2 = Worksheets("数据库")
readSheet2.Select
Dim i, c
For i = 1 To 100
c = Sheet2.Cells(2, i).Value
If IsEmpty(c) Then f = i
Next i
End Function

Public Sub tijiao()
Dim a(1 To 30) As String
Dim b As Integer
a(30) = stockread(e)
Set readsheet3 = Application.Worksheets("数据库")
o = selectfreecol(b)
readsheet3.Range(Cells(2, o), Cells(31, o)).Select
readsheet3.Activate
Dim k As Integer
Dim l As Integer
Dim o As Integer
For k = 1 To 30
l = k + 1
Worksheet.Cells(l, o).Select
Worksheet.Cells(l, o).Value = a(k)
Next k
End Sub
都有什么错误啊。怎么老是不行。


补充内容 (2013-11-11 13:16):
这是新编辑的

Public Sub tijiao()
Dim e(30)
Dim k As Integer
Dim l As Integer
Dim f As Integer
Dim c As String

Application.Goto Sheets(2).Range("d7:k18")
e(1) = Range("k7").Value
e(2) = Range("e8").V

TA的精华主题

TA的得分主题

 楼主| 发表于 2013-11-8 11:35 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
这是表补充上楼的。请大家帮助下,主要是为了工作中方便记录数据,

练习制作模.rar

20.02 KB, 下载次数: 8

TA的精华主题

TA的得分主题

 楼主| 发表于 2013-11-11 15:18 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
下面是代码:(独立研究几日,日子真苦)
读取输入区数值,选择空列,存储数据。
Public Sub tijiao()
Dim e(30)
Dim k As Integer
Dim l As Integer
Dim f As Integer
Dim c As String

Application.Goto Sheets(2).Range("d7:k18")
e(1) = Range("k7").Value
e(2) = Range("e8").Value
e(3) = Range("e10").Value
e(4) = Range("e11").Value
e(5) = Range("e12").Value
e(6) = Range("e13").Value
e(7) = Range("e14").Value
e(8) = Range("e15").Value
e(9) = Range("e16").Value
e(10) = Range("e17").Value
e(11) = Range("e18").Value
e(12) = Range("h8").Value
e(13) = Range("h9").Value
e(14) = Range("h10").Value
e(15) = Range("h11").Value
e(16) = Range("h13").Value
e(17) = Range("h14").Value
e(18) = Range("h15").Value
e(19) = Range("h17").Value
e(20) = Range("h18").Value
e(21) = Range("k8").Value
e(22) = Range("k9").Value
e(23) = Range("k10").Value
e(24) = Range("k12").Value
e(25) = Range("k13").Value
e(26) = Range("k14").Value
e(27) = Range("k15").Value
e(28) = Range("k17").Value
e(29) = Range("k18").Value

Application.Goto Sheets(5).Range("b1")

f = 0
For i = 1 To 10000
c = Sheets(5).Cells(2, i).Value
If c = "" Then f = i: Exit For


Next i


For k = 1 To 29
l = k + 1
ActiveWorkbook.Worksheets(5).Cells(l, f) = e(k)


Next k

End Sub

---------------------------------------------
清除输入区数值



Public Sub cls1()
Application.Goto Sheets(2).Range("e8")
ActiveWorkbook.Worksheets(2).Range("e8:e18") = ""
ActiveWorkbook.Worksheets(2).Range("h8:h18") = ""
ActiveWorkbook.Worksheets(2).Range("k7:k18") = ""

End Sub


练习制作模.rar

21.12 KB, 下载次数: 6

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

本版积分规则

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-12-27 19:20 , Processed in 0.030903 second(s), 11 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

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