Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 2094|回复: 6

[已解决]代码看不懂求解释呀~~

[复制链接]
发表于 2015-12-30 09:10 | 显示全部楼层 |阅读模式
本帖最后由 啦啦游游 于 2016-1-25 11:15 编辑

1.  For Each w In Workbooks
            If w.Name = Filename Then
                NewerVersion = True ' The source file is already open and my be updated
            End If
        Next w

w.Name指代的是哪些地方的内容啊?

2.  Sheets().Tab.ColorIndex = -4142 指代的是哪部分的颜色?
     和 sheets().cells().Interior.ColorIndex=-4142 有什么区别

3. Path = Cells(1, 3).comment.Text  是批注内容的意思吗?
    那没有批注运行出错怎么办

4. ActiveSheet.Protection.AllowEditRanges().Delete                     意思是什么

5.   ActiveSheet.Protection.AllowEditRanges.Add Title:="Bereich1", Range:=Range( "D3:AI10")            意思是什么


6.  If CommentHours <> "" Then
        On Error GoTo PasteData1
        sheet.Cells(Row, ColumnTotalHours).comment.Text Text:=sheet.Cells(Row, ColumnTotalHours).comment.Text & _     Person & ": " & CommentHours & Chr(10)
        GoTo PasteData2
PasteData1:
        sheet.Cells(Row, ColumnTotalHours).AddComment
        sheet.Cells(Row, ColumnTotalHours).comment.Visible = False
        sheet.Cells(Row, ColumnTotalHours).comment.Text Text:=Person & ": " & CommentHours & Chr(10)
        Resume Next
PasteData2:
    End If
            
    If CommentCosts <> "" Then
        On Error GoTo PasteData3
        sheet.Cells(Row, ColumnExtraCosts).comment.Text Text:=sheet.Cells(Row, ColumnExtraCosts).comment.Text & _ Person  & ": " & CommentCosts & Chr(10)
        GoTo PasteData4
PasteData3:
        sheet.Cells(Row, ColumnExtraCosts).AddComment
        sheet.Cells(Row, ColumnExtraCosts).comment.Visible = False
        sheet.Cells(Row, ColumnExtraCosts).comment.Text Text:=Person & ": " & CommentCosts & Chr(10)
        Resume Next
PasteData4:
    End If   

[新增!!!!]
7.   Workbooks.Open Filename:=Path & Filename, ReadOnly:=False, UpdateLinks:=3
      
     上一句里的 UpdateLinks:=3 是什么意思呢

这一大段能大概解释一下是什么吗~~~~

谢谢大家啦~~~
最佳答案
2015-12-30 09:23
本帖最后由 兰色幻想 于 2015-12-30 10:27 编辑

w.Name 已打开的工作簿名称
Sheets().Tab 工作表标签
Interior.ColorIndex是填充颜色
ActiveSheet.Protection.AllowEditRanges().Delete 受保护的允许编辑区域
ActiveSheet.Protection.AllowEditRanges.Add Title:="Bereich1", Range:=Range( "D3:AI10")   增加受保护允许编辑区域

excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2015-12-30 09:23 | 显示全部楼层    本楼为最佳答案   
本帖最后由 兰色幻想 于 2015-12-30 10:27 编辑

w.Name 已打开的工作簿名称
Sheets().Tab 工作表标签
Interior.ColorIndex是填充颜色
ActiveSheet.Protection.AllowEditRanges().Delete 受保护的允许编辑区域
ActiveSheet.Protection.AllowEditRanges.Add Title:="Bereich1", Range:=Range( "D3:AI10")   增加受保护允许编辑区域

回复

使用道具 举报

 楼主| 发表于 2015-12-30 09:29 | 显示全部楼层
兰色幻想 发表于 2015-12-30 09:23
w.Name 已打开的工作簿名称
Sheets().Tab 工作表标签
Interior.ColorIndex是字符颜色

谢谢~~

那第三个和第六个又是什么呢~?
回复

使用道具 举报

发表于 2015-12-30 10:01 | 显示全部楼层
兰版亲自出来,难得~~
Interior.ColorIndex应该是底色,而非字符颜色
第三,可以考虑加on error resume next
回复

使用道具 举报

发表于 2015-12-30 10:22 | 显示全部楼层
6.  If CommentHours  中的CommentHours 应该是自定义的一个什么变量,建议百度一下,先了解一些基础再说
回复

使用道具 举报

 楼主| 发表于 2015-12-30 13:14 | 显示全部楼层
这儿有肥猫 发表于 2015-12-30 10:01
兰版亲自出来,难得~~
Interior.ColorIndex应该是底色,而非字符颜色
第三,可以考虑加on error resume n ...

第三个完整 是这样的
   Dim Reportfile As String, Path As String, Month As String
  
    Reportfile = ActiveWorkbook.Name
    Path = Cells(1, 3).comment.Text  
    Month = ActiveSheet.Name

但是path等号右边对应的单元格没有批注,所以我不知道这句会不会有其他的含义
回复

使用道具 举报

 楼主| 发表于 2015-12-30 13:18 | 显示全部楼层
lichuanboy44 发表于 2015-12-30 10:22
6.  If CommentHours  中的CommentHours 应该是自定义的一个什么变量,建议百度一下,先了解一些基础再说

主要就是“comment”这个运用我有点不太清楚
我以为就是批注的意思,可是有的没有批注也能用,有的就不行,所以想知道comment有没有其它的意思
回复

使用道具 举报

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

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-5-4 20:44 , Processed in 0.240987 second(s), 8 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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