首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >将范围的行高设置为721 to

将范围的行高设置为721 to
EN

Stack Overflow用户
提问于 2016-06-14 08:57:39
回答 1查看 82关注 0票数 0

我在PPT中有一个Excel表,它动态地填充了来自另一个工作表的数据。第1行至第7行和第30行至36行的行高是固定的(ppt的页眉和页脚)。在从第8行到第26行的范围内,行在空时是隐藏的(我在一些行中输入了白色的"X“以保持它们的显示)。

在导出PPT模板时,我需要获得第2行到第36行的总高度为721 it,以适应我的PPT模板。

是否有可能动态调整“白色”行的行高(例如,第29行),以便为定义的范围(第2行至第36行)总共调整721 36?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-06-14 10:09:34

你可以这样做:

代码语言:javascript
运行
复制
Option Explicit

Sub main()
    Dim extraRowHeight As Double, totalRowsHeight As Double
    Dim myRowsRange As Range
    Const maxRowHeight As Double = 409 '<--| maximum allowed row height

    totalRowsHeight = 721# '<--| set the total rows height you need for the range you are to specifiy right below
    With Worksheets("MyTableSheet") '<--| change "MyTableSheet" with your actual sheet name
        extraRowHeight = totalRowsHeight - .Rows("2:36").Height '<--| calculate the extra height needed for the wanted rows range
        With .Rows(29) '<--| consider the "reservoir" row
            If .RowHeight + extraRowHeight <= maxRowHeight Then '<--| if needed extra height leads to an allowable resulting "reservoir" row height ...
                .RowHeight = .RowHeight + extraRowHeight '<--| ... then adjust "reservoir" row height
            Else
                .RowHeight = maxRowHeight '<--| ... otherwise adjust "reservoir" row to maximum allowable height ...
                MsgBox "you still need to resize some other rows height for " & totalRowsHeight - .Rows("2:36").Height & " pts more" '<--|... and inform how much there still is to go
            End If
        End With
    End With
End Sub
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37807374

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档