| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 293 人关注过本帖
标题:执行时输入a1的坐标,怎么不能出结果呢?
只看楼主 加入收藏
学习要努力
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2013-11-26
结帖率:0
收藏
 问题点数:0 回复次数:0 
执行时输入a1的坐标,怎么不能出结果呢?
反向累加
Sub test()                                                   
                                                     
Dim Rng As Range                                                   
                                                     
Dim A, B, C, D, M, N, I, mRange As Integer                                                   
                                                     
If [a1] = "" Then                                                   
                                                     
    MsgBox "请先在A1单元格里输入起点单元格坐标", vbOKOnly, ""                                                   
                                                     
    Exit Sub                                                   
                                                     
End If                                                   
                                                     
Set Rng = Range([a1].Value)                                                   
                                                     
M = 1                                                   
                                                     
I = 1                                                   
                                                     
mRange = WorksheetFunction.Min(Rng.Column, Rng.Row) * 2 * (WorksheetFunction.Min(Rng.Column, Rng.Row) * 2 - 1)                                                   
                                                     
Rng = M                                                   
                                                     
Rng.Interior.Color = vbYellow                                                   
                                                     
M = M + 1                                                   
                                                     
Rng.Offset(0, 1) = M                                                   
                                                     
Rng.Offset(0, 1).Interior.Color = RGB(255 - Int(M / mRange * 255), Int(M / mRange * 255), Int(M / mRange * 255))                                                   
                                                     
Do While I < Rng.Column And I < Rng.Row                                                   
                                                     
    For A = Rng.Offset(-I, I).Column To Rng.Offset(-I, -I + 1).Column Step -1                                                   
                                                     
        M = M + 1                                                   
                                                     
        Cells(Rng.Row - I, A) = M                                                   
                                                     
        Cells(Rng.Row - I, A).Interior.Color = RGB(255 - Int(M / mRange * 255), Int(M / mRange * 255), Int(M / mRange * 255))                                                   
                                                     
    Next A                                                   
                                                     
    For B = Rng.Offset(-I, -I).Row To Rng.Offset(I - 1, -I).Row                                                   
                                                     
        M = M + 1                                                   
                                                     
        Cells(B, Rng.Column - I) = M                                                   
                                                     
        Cells(B, Rng.Column - I).Interior.Color = RGB(255 - Int(M / mRange * 255), Int(M / mRange * 255), Int(M / mRange * 255))                                                   
                                                     
    Next B                                                   
                                                     
    For C = Rng.Offset(I, -I).Column To Rng.Offset(I, I).Column                                                   
                                                     
        M = M + 1                                                   
                                                     
        Cells(Rng.Row + I, C) = M                                                   
                                                     
        Cells(Rng.Row + I, C).Interior.Color = RGB(255 - Int(M / mRange * 255), Int(M / mRange * 255), Int(M / mRange * 255))                                                   
                                                     
    Next C                                                   
                                                     
    I = I + 1                                                   
                                                     
    For D = Rng.Offset(I - 1, I).Row To Rng.Offset(-I + 1, I).Row Step -1                                                   
                                                     
        M = M + 1                                                   
                                                     
        Cells(D, Rng.Column + I) = M                                                   
                                                     
        Cells(D, Rng.Column + I).Interior.Color = RGB(255 - Int(M / mRange * 255), Int(M / mRange * 255), Int(M / mRange * 255))                                                   
                                                     
    Next D                                                   
                                                     
Loop                                                   
                                                     
End Sub                                                   
2013-11-27 10:15
快速回复:执行时输入a1的坐标,怎么不能出结果呢?
数据加载中...
 
   



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

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