Excel精英培训网

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

[已解决]帮我看下这句代码哪有问题。不能正常运行。

[复制链接]
发表于 2014-4-13 00:10 | 显示全部楼层 |阅读模式
本帖最后由 跑跑2014 于 2014-4-13 22:30 编辑

  .Cells(.Cells(i, "n"), .Cells(i, "t")).Borders(xlInsideVertical).LineStyle = xlNone '去掉竖线
多谢。
最佳答案
2014-4-13 08:28
跑跑2014 发表于 2014-4-13 00:23
Dim i As Long
    For i = 2 To .Cells(Rows.Count, "Y").End(xlUp).Row
        If InStr(.Cells( ...

.Cells(.Cells(i, "n"), .Cells(i, "t")).Borders.LineStyle = xlNone
'           .Cells(.Cells(i, "n"), .Cells(i, "t")).Borders(xlInsideVertical).LineStyle = xlNone '去掉竖线


改为这样试试:
.range(.Cells(i, "n"), .Cells(i, "t")).Borders.LineStyle = xlNone
'           .range(.Cells(i, "n"), .Cells(i, "t")).Borders(xlInsideVertical).LineStyle = xlNone '去掉竖线
发表于 2014-4-13 00:17 | 显示全部楼层
.Cells(.Cells(i, "n"), .Cells(i, "t")).Borders.LineStyle = xlNone '去掉竖线
直接全去掉吧。
回复

使用道具 举报

 楼主| 发表于 2014-4-13 00:23 | 显示全部楼层
hwc2ycy 发表于 2014-4-13 00:17
.Cells(.Cells(i, "n"), .Cells(i, "t")).Borders.LineStyle = xlNone '去掉竖线
直接全去掉吧。


Dim i As Long
    For i = 2 To .Cells(Rows.Count, "Y").End(xlUp).Row
        If InStr(.Cells(i, "Y"), "汇总") > 0 Then
            .Cells(i, "Y").Cut .Cells(i, "D")
           .Cells(i, "n").Value = "在租数量:" & .Cells(i - 1, "n").Value
           .Cells(.Cells(i, "n"), .Cells(i, "t")).Borders.LineStyle = xlNone
'           .Cells(.Cells(i, "n"), .Cells(i, "t")).Borders(xlInsideVertical).LineStyle = xlNone '去掉竖线
           
        End If
    Next i
'
End With
代码运行到这句就报错,您写的那句也是,如何改 呢
回复

使用道具 举报

发表于 2014-4-13 00:26 | 显示全部楼层
跑跑2014 发表于 2014-4-13 00:23
Dim i As Long
    For i = 2 To .Cells(Rows.Count, "Y").End(xlUp).Row
        If InStr(.Cells( ...

传附件。


回复

使用道具 举报

发表于 2014-4-13 08:28 | 显示全部楼层    本楼为最佳答案   
跑跑2014 发表于 2014-4-13 00:23
Dim i As Long
    For i = 2 To .Cells(Rows.Count, "Y").End(xlUp).Row
        If InStr(.Cells( ...

.Cells(.Cells(i, "n"), .Cells(i, "t")).Borders.LineStyle = xlNone
'           .Cells(.Cells(i, "n"), .Cells(i, "t")).Borders(xlInsideVertical).LineStyle = xlNone '去掉竖线


改为这样试试:
.range(.Cells(i, "n"), .Cells(i, "t")).Borders.LineStyle = xlNone
'           .range(.Cells(i, "n"), .Cells(i, "t")).Borders(xlInsideVertical).LineStyle = xlNone '去掉竖线

点评

呵呵,看得细致。  发表于 2014-4-13 09:46
回复

使用道具 举报

 楼主| 发表于 2014-4-13 20:56 | 显示全部楼层
810126769 发表于 2014-4-13 08:28
.Cells(.Cells(i, "n"), .Cells(i, "t")).Borders.LineStyle = xlNone
'           .Cells(.Cells(i, " ...

谢谢你帮我找出毛病所在。我记得可以用 那种方法写,为什么不对呢。
回复

使用道具 举报

发表于 2014-4-13 20:59 | 显示全部楼层
跑跑2014 发表于 2014-4-13 20:56
谢谢你帮我找出毛病所在。我记得可以用 那种方法写,为什么不对呢。

cells只能表示某一个单元格,不能用来表示一个单元格区域。
只有range既可以表示一个单元格,也可以表示单元格区域。
回复

使用道具 举报

 楼主| 发表于 2014-4-13 21:01 | 显示全部楼层
810126769 发表于 2014-4-13 20:59
cells只能表示某一个单元格,不能用来表示一个单元格区域。
只有range既可以表示一个单元格,也可以表示 ...

谢谢……这下明白了。
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-25 23:54 , Processed in 0.238414 second(s), 11 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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