楼主: sansha3480
2865 4

[休闲其它] 【VBA】Powerpoint 表格每行交替填充颜色 [推广有奖]

  • 17关注
  • 1粉丝

已卖:50份资源

本科生

80%

还不是VIP/贵宾

-

TA的文库  其他...

Hedge Fund Operations

威望
0
论坛币
2354 个
通用积分
35.3844
学术水平
2 点
热心指数
2 点
信用等级
1 点
经验
2024 点
帖子
56
精华
0
在线时间
131 小时
注册时间
2013-6-27
最后登录
2024-4-9

楼主
sansha3480 发表于 2019-1-19 17:28:23 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
Sub 交替填充表格行背景色()

Dim sh As Integer
Dim i As Integer
Dim j As Integer
Dim x As Integer
x = 1
'分别确定标题行色、奇数行颜色和偶数行颜色
biaoti = RGB(217, 217, 217)
jishu = RGB(0, 0, 0)
oushu = RGB(12, 17, 127)

        With ActivePresentation.Slides(1)
            For sh = 1 To .Shapes.Count
                If .Shapes(sh).HasTable Then

                    With ActivePresentation.Slides(1).Shapes(sh).Table
                        '确定表格行列数
                        iCol = .Columns.Count
                        iRow = .Rows.Count

                        '令第一个单元格的填充色为标题色
                        With .Cell(1, 1)
                            .Shape.Fill.ForeColor.RGB = biaoti
                        End With

                        '填充标题行颜色,判断下一行第一个单元格的填充颜色是否与标题填充色一致,如一致换到下一行
                        While .Cell(x, 1).Shape.Fill.ForeColor.RGB = biaoti
                            For m = 1 To iCol
                                .Cell(x, m).Shape.Fill.ForeColor.RGB = biaoti
                            Next
                            x = x + 1
                        Wend
                        '对标题行之外的表格范围,按行交替填充单元格颜色
                                For i = x To iCol
                                    If (i - x + 1) Mod 2 = 1 Then
                                            tianchong = jishu
                                        Else
                                            tianchong = oushu
                                    End If
                                    '开始填充当前行单元格
                                    For j = 1 To iRow
                                        Set oCell = .Cell(i, j)
                                        With oCell
                                            .Shape.Fill.ForeColor.RGB = tianchong
                                        End With
                                    Next j
                                    '当前行填充完毕
                                Next i
                    End With

                End If
            Next
        End With
End Sub
压缩包预览 PPT

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:powerpoint Point Power VBA int

VBA.rar
下载链接: https://bbs.pinggu.org/a-2716389.html

13.18 MB

本附件包括:

  • PowerPoint 2013 Developer Documentation.chm
  • Excel 2013 Developer Documentation.chm
  • 在表格中交替行填充颜色.pptm

沙发
phipe 发表于 2019-1-27 00:16:36
谢谢分享,学习下

藤椅
sansha3480 发表于 2019-1-27 01:36:28
phipe 发表于 2019-1-27 00:16
谢谢分享,学习下
感谢回复,这个论坛好像没有地方发类帖子哟,所以就发到这里了。

板凳
phipe 发表于 2019-1-27 10:28:45
sansha3480 发表于 2019-1-27 01:36
感谢回复,这个论坛好像没有地方发类帖子哟,所以就发到这里了。
有的,有个Excel专版,可以转那边过去: https://bbs.pinggu.org/forum-136-1.html

报纸
sansha3480 发表于 2019-1-27 11:41:34 来自手机
phipe 发表于 2019-1-27 10:28
有的,有个Excel专版,可以转那边过去: https://bbs.pinggu.org/forum-136-1.html
感谢!

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

本版微信群
jg-xs1
拉您进交流群
GMT+8, 2026-1-10 01:27