ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

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

带你入门VBA系列之:不懂的代码快点贴过来

[复制链接]

TA的精华主题

TA的得分主题

发表于 2007-1-8 13:47 | 显示全部楼层
QUOTE:
以下是引用blue_prince在2007-1-8 13:06:00的发言:

 Range("A1").Select
    ActiveCell.FormulaR1C1 = "时间" '当前单元格的公式为"时间",其实也就是值
    Range("A2:a" & (count - 1)).Select ‘count是一个变量,现在是选中了一个区域,从a2一直到count行
    Selection.FormulaR1C1 = "=DATE(2006,RC[1],RC[2])" '对选中的区域同时设置公式,你可以在工作表里改工具》选项》常规,R1C1格式(钩中),然后在单元格里输入=DATE(2006,RC[1],RC[2]),看看它的引用(可以到论坛搜索RC格式的帮助)
    
    Range("A1:P20").Sort Key1:=Range("A2"), Order1:=xlAscending, Key2:=Range( _
        "E2"), Order2:=xlAscending, Header:=xlYes, OrderCustom:=1 ’对A1:P20排序,按第一a2单元格升序,第二e2单元格升序,有标题

请教各位,以上代码是什么意思呀,我只明白选 中A1,而后面就不懂了

FYI

TA的精华主题

TA的得分主题

发表于 2007-1-8 14:01 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册

   用一段代码提取excel里面的超链接,但是得到的超链接顺序与sheet1里面的是不一样的
   请高手指点有没有啥办法
   Sub test()
   Dim irow%
   Dim h
   irow = 1
   For Each h In Worksheets(1).Hyperlinks
         Worksheets(2).Cells(irow, 1) = h.Name
         irow = irow + 1
   Next
   End Sub

TA的精华主题

TA的得分主题

发表于 2007-1-8 14:23 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
QUOTE:
以下是引用cariage在2007-1-8 14:01:59的发言:

   用一段代码提取excel里面的超链接,但是得到的超链接顺序与sheet1里面的是不一样的
   请高手指点有没有啥办法
   Sub test()
   Dim irow%
   Dim h
   irow = 1
   For Each h In Worksheets(1).Hyperlinks
         Worksheets(2).Cells(irow, 1) = h.Name
         irow = irow + 1
   Next
   End Sub

建议另起新贴求助!

TA的精华主题

TA的得分主题

发表于 2007-1-8 16:05 | 显示全部楼层

TA的精华主题

TA的得分主题

发表于 2007-1-9 20:15 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助

Columns("a:j").Select

Selection.Delete Shift:=xlLeft

Rows("1:10").Select

Selection.Delete Shift:=xlUp

Columns("a:a").Select

请教一下,这个是什么意思啊??谢谢!~~

TA的精华主题

TA的得分主题

发表于 2007-1-10 14:49 | 显示全部楼层

FD:
   
    ActiveCell.Offset(1, 0).Select
   
    If ActiveCell <> "" Then
         
   
    If ActiveCell.Offset(1, 0) <> ActiveCell Then
   
        ActiveCell.Offset(0, 28) = ""
       
         Else
              
        ActiveCell.Offset(0, 28) = ActiveCell.Offset(1, 3)

       
    End If
   
        If ActiveCell.Offset(0, 7) <> "" Then
        
        MRT = ActiveCell.Offset(0, 4) * ActiveCell.Offset(0, 7) + ActiveCell.Offset(0, 5)
        NRT = 0
       
RT:
       

        If ActiveCell <> ActiveCell.Offset(1, 0) Then
           
        ActiveCell.Offset(-NRT, 0).Select
       
        Else
       
        ActiveCell.Offset(1, 0).Select
       
        NRT = NRT + 1
      
        MRT = MRT + ActiveCell.Offset(0, 4) * ActiveCell.Offset(0, 7) + ActiveCell.Offset(0, 5)
       
        GoTo RT

      
       End If

        ActiveCell.Offset(0, 26) = MRT
       
        End If
       
       
        AFT = 0
        AY = 0
       
        NFT = 0
       
        If ActiveCell.Offset(0, 7) <> "" Then
       
        If ActiveCell.Offset(0, 9) <> "" Then
        
       
        If Mid(ActiveCell.Offset(0, 3), 2, 1) = "E" Then
       
        AY = AY + ActiveCell.Offset(0, 12) / 60
       
        Else
       
        AFT = AFT + ActiveCell.Offset(0, 12) * 1
       
        End If
       
FT:
       

        If ActiveCell <> ActiveCell.Offset(-1, 0) Then
           
        ActiveCell.Offset(NFT, 0).Select
       
        Else
       
        ActiveCell.Offset(-1, 0).Select
       
        NFT = NFT + 1
      
        If Mid(ActiveCell.Offset(0, 3), 2, 1) = "E" Then
       
        AY = AY + ActiveCell.Offset(0, 12) / 60
       
        Else
       
        AFT = AFT + ActiveCell.Offset(0, 12) * 1
       
        End If
       
        GoTo FT
      
       End If
      
       End If
     
        ActiveCell.Offset(0, 25) = AFT
       
        ActiveCell.Offset(0, 27) = AFT * 78.39 / 60 + AY

    End If
   
    Else
  
    End
   
    End If
   

   
    If Mid(ActiveCell.Offset(0, 3), 2, 1) = "E" Then
   
    If ActiveCell.Offset(0, 10) = "W" Or ActiveCell.Offset(0, 10) = "M" Or ActiveCell.Offset(0, 10) = "S" Then
   
        WCID = "0"
        W2C = "0"
        MO = "0"
        ITE = "0"
        LSD = "0"
        STQ = "0"
        RT = "0"
        N = "0"
        NXW = "0"
        NRT = "0"
        MOS = "0"
        SCM = "0"
           
                   
    MO = ActiveCell
    WCID = Mid(ActiveCell.Offset(0, 3), 1, 5)
    W2C = Mid(ActiveCell.Offset(0, 3), 1, 2)
    MA = ActiveCell.Offset(0, -1)
    ITE = ActiveCell.Offset(0, 1)
    LSD = ActiveCell.Offset(0, 18)
    STQ = ActiveCell.Offset(0, 8)
    RT = ActiveCell.Offset(0, 11)
    NXW = ActiveCell.Offset(0, 28)
    NRT = ActiveCell.Offset(0, 26)
    MOS = ActiveCell.Offset(0, 10)
    SCM = ActiveCell.Offset(0, 24)
   
    Sheets(WCID).Select
   
    ActiveCell.Offset(1, 0).Select
    ActiveCell = WCID
    ActiveCell.Offset(0, 1) = MA
    ActiveCell.Offset(0, 2) = MO
    ActiveCell.Offset(0, 3) = ITE
    ActiveCell.Offset(0, 4) = LSD
    ActiveCell.Offset(0, 5) = STQ
    ActiveCell.Offset(0, 6) = RT
    ActiveCell.Offset(0, 7) = NXW
    ActiveCell.Offset(0, 8) = NRT
    ActiveCell.Offset(0, 9) = MOS
    ActiveCell.Offset(0, 10) = SCM
   
   
    End If
   
    End If
   
   
    Sheets("SELMO").Select
   
GoTo FD
 
End Sub


TA的精华主题

TA的得分主题

发表于 2007-1-10 14:49 | 显示全部楼层

FD:
   
    ActiveCell.Offset(1, 0).Select
   
    If ActiveCell <> "" Then
         
   
    If ActiveCell.Offset(1, 0) <> ActiveCell Then
   
        ActiveCell.Offset(0, 28) = ""
       
         Else
              
        ActiveCell.Offset(0, 28) = ActiveCell.Offset(1, 3)

       
    End If
   
        If ActiveCell.Offset(0, 7) <> "" Then
        
        MRT = ActiveCell.Offset(0, 4) * ActiveCell.Offset(0, 7) + ActiveCell.Offset(0, 5)
        NRT = 0
       
RT:
       

        If ActiveCell <> ActiveCell.Offset(1, 0) Then
           
        ActiveCell.Offset(-NRT, 0).Select
       
        Else
       
        ActiveCell.Offset(1, 0).Select
       
        NRT = NRT + 1
      
        MRT = MRT + ActiveCell.Offset(0, 4) * ActiveCell.Offset(0, 7) + ActiveCell.Offset(0, 5)
       
        GoTo RT

      
       End If

        ActiveCell.Offset(0, 26) = MRT
       
        End If
       
       
        AFT = 0
        AY = 0
       
        NFT = 0
       
        If ActiveCell.Offset(0, 7) <> "" Then
       
        If ActiveCell.Offset(0, 9) <> "" Then
        
       
        If Mid(ActiveCell.Offset(0, 3), 2, 1) = "E" Then
       
        AY = AY + ActiveCell.Offset(0, 12) / 60
       
        Else
       
        AFT = AFT + ActiveCell.Offset(0, 12) * 1
       
        End If
       
FT:
       

        If ActiveCell <> ActiveCell.Offset(-1, 0) Then
           
        ActiveCell.Offset(NFT, 0).Select
       
        Else
       
        ActiveCell.Offset(-1, 0).Select
       
        NFT = NFT + 1
      
        If Mid(ActiveCell.Offset(0, 3), 2, 1) = "E" Then
       
        AY = AY + ActiveCell.Offset(0, 12) / 60
       
        Else
       
        AFT = AFT + ActiveCell.Offset(0, 12) * 1
       
        End If
       
        GoTo FT
      
       End If
      
       End If
     
        ActiveCell.Offset(0, 25) = AFT
       
        ActiveCell.Offset(0, 27) = AFT * 78.39 / 60 + AY

    End If
   
    Else
  
    End
   
    End If
   

   
    If Mid(ActiveCell.Offset(0, 3), 2, 1) = "E" Then
   
    If ActiveCell.Offset(0, 10) = "W" Or ActiveCell.Offset(0, 10) = "M" Or ActiveCell.Offset(0, 10) = "S" Then
   
        WCID = "0"
        W2C = "0"
        MO = "0"
        ITE = "0"
        LSD = "0"
        STQ = "0"
        RT = "0"
        N = "0"
        NXW = "0"
        NRT = "0"
        MOS = "0"
        SCM = "0"
           
                   
    MO = ActiveCell
    WCID = Mid(ActiveCell.Offset(0, 3), 1, 5)
    W2C = Mid(ActiveCell.Offset(0, 3), 1, 2)
    MA = ActiveCell.Offset(0, -1)
    ITE = ActiveCell.Offset(0, 1)
    LSD = ActiveCell.Offset(0, 18)
    STQ = ActiveCell.Offset(0, 8)
    RT = ActiveCell.Offset(0, 11)
    NXW = ActiveCell.Offset(0, 28)
    NRT = ActiveCell.Offset(0, 26)
    MOS = ActiveCell.Offset(0, 10)
    SCM = ActiveCell.Offset(0, 24)
   
    Sheets(WCID).Select
   
    ActiveCell.Offset(1, 0).Select
    ActiveCell = WCID
    ActiveCell.Offset(0, 1) = MA
    ActiveCell.Offset(0, 2) = MO
    ActiveCell.Offset(0, 3) = ITE
    ActiveCell.Offset(0, 4) = LSD
    ActiveCell.Offset(0, 5) = STQ
    ActiveCell.Offset(0, 6) = RT
    ActiveCell.Offset(0, 7) = NXW
    ActiveCell.Offset(0, 8) = NRT
    ActiveCell.Offset(0, 9) = MOS
    ActiveCell.Offset(0, 10) = SCM
   
   
    End If
   
    End If
   
   
    Sheets("SELMO").Select
   
GoTo FD
 
End Sub


TA的精华主题

TA的得分主题

发表于 2007-1-10 14:51 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册

FD:
   
    ActiveCell.Offset(1, 0).Select
   
    If ActiveCell <> "" Then
         
   
    If ActiveCell.Offset(1, 0) <> ActiveCell Then
   
        ActiveCell.Offset(0, 28) = ""
       
         Else
              
        ActiveCell.Offset(0, 28) = ActiveCell.Offset(1, 3)

       
    End If
   
        If ActiveCell.Offset(0, 7) <> "" Then
        
        MRT = ActiveCell.Offset(0, 4) * ActiveCell.Offset(0, 7) + ActiveCell.Offset(0, 5)
        NRT = 0
       
RT:
       

        If ActiveCell <> ActiveCell.Offset(1, 0) Then
           
        ActiveCell.Offset(-NRT, 0).Select
       
        Else
       
        ActiveCell.Offset(1, 0).Select
       
        NRT = NRT + 1
      
        MRT = MRT + ActiveCell.Offset(0, 4) * ActiveCell.Offset(0, 7) + ActiveCell.Offset(0, 5)
       
        GoTo RT

      
       End If

        ActiveCell.Offset(0, 26) = MRT
       
        End If
       
       
        AFT = 0
        AY = 0
       
        NFT = 0
       
        If ActiveCell.Offset(0, 7) <> "" Then
       
        If ActiveCell.Offset(0, 9) <> "" Then
        
       
        If Mid(ActiveCell.Offset(0, 3), 2, 1) = "E" Then
       
        AY = AY + ActiveCell.Offset(0, 12) / 60
       
        Else
       
        AFT = AFT + ActiveCell.Offset(0, 12) * 1
       
        End If
       
FT:
       

        If ActiveCell <> ActiveCell.Offset(-1, 0) Then
           
        ActiveCell.Offset(NFT, 0).Select
       
        Else
       
        ActiveCell.Offset(-1, 0).Select
       
        NFT = NFT + 1
      
        If Mid(ActiveCell.Offset(0, 3), 2, 1) = "E" Then
       
        AY = AY + ActiveCell.Offset(0, 12) / 60
       
        Else
       
        AFT = AFT + ActiveCell.Offset(0, 12) * 1
       
        End If
       
        GoTo FT
      
       End If
      
       End If
     
        ActiveCell.Offset(0, 25) = AFT
       
        ActiveCell.Offset(0, 27) = AFT * 78.39 / 60 + AY

    End If
   
    Else
  
    End
   
    End If
   

   
    If Mid(ActiveCell.Offset(0, 3), 2, 1) = "E" Then
   
    If ActiveCell.Offset(0, 10) = "W" Or ActiveCell.Offset(0, 10) = "M" Or ActiveCell.Offset(0, 10) = "S" Then
   
        WCID = "0"
        W2C = "0"
        MO = "0"
        ITE = "0"
        LSD = "0"
        STQ = "0"
        RT = "0"
        N = "0"
        NXW = "0"
        NRT = "0"
        MOS = "0"
        SCM = "0"
           
                   
    MO = ActiveCell
    WCID = Mid(ActiveCell.Offset(0, 3), 1, 5)
    W2C = Mid(ActiveCell.Offset(0, 3), 1, 2)
    MA = ActiveCell.Offset(0, -1)
    ITE = ActiveCell.Offset(0, 1)
    LSD = ActiveCell.Offset(0, 18)
    STQ = ActiveCell.Offset(0, 8)
    RT = ActiveCell.Offset(0, 11)
    NXW = ActiveCell.Offset(0, 28)
    NRT = ActiveCell.Offset(0, 26)
    MOS = ActiveCell.Offset(0, 10)
    SCM = ActiveCell.Offset(0, 24)
   
    Sheets(WCID).Select
   
    ActiveCell.Offset(1, 0).Select
    ActiveCell = WCID
    ActiveCell.Offset(0, 1) = MA
    ActiveCell.Offset(0, 2) = MO
    ActiveCell.Offset(0, 3) = ITE
    ActiveCell.Offset(0, 4) = LSD
    ActiveCell.Offset(0, 5) = STQ
    ActiveCell.Offset(0, 6) = RT
    ActiveCell.Offset(0, 7) = NXW
    ActiveCell.Offset(0, 8) = NRT
    ActiveCell.Offset(0, 9) = MOS
    ActiveCell.Offset(0, 10) = SCM
   
   
    End If
   
    End If
   
   
    Sheets("SELMO").Select
   
GoTo FD
 
End Sub


TA的精华主题

TA的得分主题

发表于 2007-1-12 15:06 | 显示全部楼层
QUOTE:
以下是引用gho_friend在2007-1-9 20:15:45的发言:

Columns("a:j").Select '选择a:j列

Selection.Delete Shift:=xlLeft '删除这些选中的列

Rows("1:10").Select '1到10行选择

Selection.Delete Shift:=xlUp 's删除这些选中的行

Columns("a:a").Select 'a列选择

请教一下,这个是什么意思啊??谢谢!~~

FYI

TA的精华主题

TA的得分主题

发表于 2007-1-12 15:08 | 显示全部楼层

To eprecious,版主在一楼说的很清楚,代码保持在十行左右,这么一大篇怎么看啊

建议你单独发贴求助,在里面上传你的附件,及哪些代码你是看不明白的!

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

本版积分规则

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

GMT+8, 2024-11-19 22:33 , Processed in 0.038614 second(s), 6 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

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

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

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