| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1311 人关注过本帖
标题:能不能转换代码?
只看楼主 加入收藏
asad
Rank: 1
等 级:新手上路
威 望:1
帖 子:68
专家分:0
注 册:2019-12-6
结帖率:66.67%
收藏
 问题点数:0 回复次数:2 
能不能转换代码?
能不能把下面vb代码转换成代码?

Sub test()
    Dim wb As Excel.Workbook, sh As Excel.Worksheet, c As Excel.Range, r As Excel.Range, rng As Excel.Range, lr As Long, l As Long, m As Long
    Dim a, b, t, d As Object, i As Long, arr, brr()
    Set d = CreateObject("scripting.dictionary")
    a = Array("a", "d")
    b = Array("c", "e")
    For i = 0 To UBound(a)
        d(a(i)) = b(i)
    Next
    xlapp.ScreenUpdating = False
    Set sh = xlapp.ActiveSheet
    Set rng = xlapp.Range("A3:W3").Value
    Set wb = GetObject(xlapp.ActiveWorkbook.Path & "\Book.xls")
    k= sh.UsedRange.Find("*", , -4163, , 1, 2).Row + 1
    With wb.Sheets(1)
        lr = .Range("b65536").End(Xlup).Row - 1
        With .Rows(1)
            For Each r In rng
                t = d(r.Value)
                If t <> "" Then
                    Set c = .Find(d(r.Value), , , 1)
                    If Not c Is Nothing Then
                        arr = c.Offset(1).Resize(lr + 1).Value
                        ReDim brr(1 To lr * 3, 1 To 1)
                        m = 0
                        For i = 1 To lr
                            For l = m + 1 To m + 3
                                brr(l, 1) = arr(i, 1)
                            Next
                            m = m + 3
                        Next
                        sh.Cells(k, r.Column).Resize(lr * 3).Value = brr
                    End If
                End If
            Next
        End With
    End With
    wb.Close False
    xlapp.ScreenUpdating = True
End Sub

[此贴子已经被作者于2022-6-26 19:32编辑过]

搜索更多相关主题的帖子: 代码 End Excel Set Value 
2022-06-22 15:18
asad
Rank: 1
等 级:新手上路
威 望:1
帖 子:68
专家分:0
注 册:2019-12-6
收藏
得分:0 
帮个忙??

[此贴子已经被作者于2022-7-6 11:20编辑过]

2022-07-06 11:18
zhangcanwei
Rank: 3Rank: 3
等 级:论坛游侠
威 望:5
帖 子:63
专家分:135
注 册:2010-7-4
收藏
得分:0 
中添加一个纯代码模块文件,把你的代码复制进去,然后改动有错误提示的地方,就行了
2022-08-01 07:29
快速回复:能不能转换代码?
数据加载中...
 
   



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

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