游客:  注册 | 登录 | 搜索 | 帮助
3s地带



标题: 无奈的问题excel vba
hqd0571
疾风
Rank: 4Rank: 4



UID 12311
精华 0
积分 492
帖子 232
现金 482
贡献值 0
阅读权限 40
注册 2007-11-7
无奈的问题excel vba
没办法,只好请教大家了。!
我想上传二个工作薄,但是这里只能上传一个。
简单的说说吧:我有一个工作薄,里面全是原始数据未经处理,还有一个工作薄,里面根据地区分成8个左右的工作表,要将第一个工作薄中的数据传入第二个工作薄。

应该怎么写?
请大家帮帮忙。

顶部
reugess
疾风
Rank: 4Rank: 4



UID 12592
精华 0
积分 463
帖子 411
现金 453
贡献值 0
阅读权限 40
注册 2007-11-7
假设要获得D:\Book1.xls文件Sheet1表中的内容:
Private Sub CommandButton1_Click()
p = "D:"
f = "book1.xls"
s = "Sheet1"
For i = 1 To 10
For j = 1 To 9
a = Cells(j, i).Address
Cells(j, i) = GetValue(p, f, s, a)
Next j
Next i
End Sub
Private Function GetValue(path, file, sheet, ref)
' 从未打开的Excel文件中检索数据
Dim arg As String
' 确保该文件存在
If Right(path, 1) <> "\" Then path = path & "\"
If Dir(path & file) = "" Then
GetValue = "File Not Found"
MsgBox (path & file & " 文件不存在")
End
End If
' 创建变量
arg = "'" & path & "[" & file & "]" & sheet & "'!" & _
Range(ref).Range("A1").Address(, , xlR1C1)
' 执行XLM 宏
GetValue = ExecuteExcel4Macro(arg)
End Function
看附件
附件:Book1.rar

  
顶部


 
当前时区 GMT+8, 现在时间是 2008-12-4 15:42 清除 Cookies - 联系我们 - 3S地带 - Archiver - WAP - 赣ICP备07006302号
Powered by Discuz! 5.5.0  © Processed in 0.025137 second(s), 6 queries , Gzip enabled