Excel精英培训网

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

[已解决]求助!!!如何将标色的对应列下的字母提出,如果一行没有,默认对应列

[复制链接]
发表于 2012-6-24 16:42 | 显示全部楼层 |阅读模式
如何将标色的对应列下的字母提出,如果一行没有,默认对应列
最佳答案
2012-6-24 17:01
Sub test()
    For r = 4 To Range("c65536").End(xlUp).Row
        For c = 3 To 8
            If Cells(r, c).Interior.ColorIndex = 3 Then
                t = c
                Cells(r + 1, 11) = Cells(r + 1, t).Value
                Exit For
            End If
        Next
        If c = 9 Then Cells(r + 1, 11) = Cells(r + 1, t)
    Next
End Sub

Book2.zip

2.12 KB, 下载次数: 10

发表于 2012-6-24 17:01 | 显示全部楼层    本楼为最佳答案   
Sub test()
    For r = 4 To Range("c65536").End(xlUp).Row
        For c = 3 To 8
            If Cells(r, c).Interior.ColorIndex = 3 Then
                t = c
                Cells(r + 1, 11) = Cells(r + 1, t).Value
                Exit For
            End If
        Next
        If c = 9 Then Cells(r + 1, 11) = Cells(r + 1, t)
    Next
End Sub
回复

使用道具 举报

 楼主| 发表于 2012-6-24 23:13 | 显示全部楼层
Zipall 发表于 2012-6-24 17:01
Sub test()
    For r = 4 To Range("c65536").End(xlUp).Row
        For c = 3 To 8

非常感谢

还有一个疑问,如果第一列前再加一列,代码应该怎么改呢,谢谢!!!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-17 08:12 , Processed in 0.288855 second(s), 12 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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