标题:求助,VB操作excel
取消只看楼主
zhl810103
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2015-6-8
结帖率:50%
已结贴  问题点数:20 回复次数:0 
求助,VB操作excel
通过DSF工作簿中YSJ工作表C2单元格的日期,在其他工作表中查询相同的日期并定位在其向下一单元格,帮看一下代码,新手谢谢。
Set xlbook = xlapp.Workbooks.Open(App.Path& "\dsf.xls", , , , "2011")
Set xlsheet = xlbook.Worksheets("YSJ")
Dim rng As Range, st, sh As Workbook, x
For x = 1 To 48
If Cells.Item(2, 3).Value <> "" Then
st = Cells.Item(2, 3).Value
    For Eachsh In Sheets
    If sh.Name<> "YSJ" Then
    Set rng = sh.Cells.Find(st)
    If Not rng Is Nothing Then
Application.Gotorng.Offset(x)
    Exit For
    End If
    End If
    Next
    ActiveCell.FormulaR1C1 = "=SUMIFS(YSJ!C[-7],YSJ!C[-10],RC[-9],YSJ!C[-9],""汇总"")"
rng.Offset(x).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
    Else
MsgBox "无记录": Exit Sub
    End If
    Next x
搜索更多相关主题的帖子: 2011 工作表 excel 
2015-07-16 18:03



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-455459-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.288427 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved