使用REPT功能设置行高

Thanks to AlexJ for suggesting a great use for the REPT function – setting a minimum row height. He uses this technique to add a bit of spacing in his tables, so they’re easier to read.

感谢AlexJ为REPT功能提供一个很好的建议-设置最小行高。 他使用这种技术在表中增加了一些间距,因此更易于阅读。

You can watch the steps in this video (or watch it on YouTube), and the step-by-step instructions are below the video.

您可以观看此视频中的步骤(或在YouTube上观看 ),分步说明在视频下方。

演示地址

在Excel列表中添加空间 (Add Space in an Excel List)

For example, here is my To Do list, with a few items to work on, around the house. Most of the Task Descriptions are short, and fit in a single line.

例如,这是我的待办事项清单,里面有一些待处理的物品。 大多数任务描述都很简短,可以放在一行中。

reptrowheight02

When I select all the rows, and use the AutoFit feature, either with the Ribbon command

当我选择所有行并使用“自动调整”功能时,可以使用功能区命令

reptrowheight10

or by double-clicking on the line between the row numbers,

或双击行号之间的行,

reptrowheight11

it squashes everything together.

它将所有东西压缩在一起。

reptrowheight01

The list is readable, but it would be easier on the eyes with a bit of white space at the top and bottom of each row.

该列表是可读的,但在每一行的顶部和底部都留有一些空白,这在眼睛上会更容易。

Yes, it’s a small detail, but if you’re staring at a long list all day, it could make a real difference in how blurry your eyes are, at the end of the day!

是的,这是一个很小的细节,但是如果您整天盯着一个长长的清单,那么到一天结束时,它可能会真正改变您的眼睛模糊!

使用REPT设置行高 (Use REPT To Set Row Height)

With AlexJ’s trick, you can add another column in the table, with a REPT formula.

使用AlexJ的技巧,您可以在表中添加带有REPT公式的另一列。

=REPT(CHAR(10),2)

= REPT(字符(10),2)

The CHAR function, with code 10, inserts a line break, so this example adds 2 line breaks in the cell.

代码为10 的CHAR函数插入一个换行符,因此此示例在单元格中添加了两个换行符。

reptrowheight03

看人物 (See the Characters)

You can hide the Spacing column, after you’ve set up the formula, so it doesn’t appear in the printed version.

设置公式后,您可以隐藏“间距”列,这样它就不会出现在打印版本中。

If you want to see something in the cell, you could add a character, such a a Pipe, so you remember that the cell isn’t empty

如果要在单元格中看到某些内容,可以添加一个字符,例如“管道”,以便记住单元格不为空

=REPT("|" & CHAR(10),2)

= REPT(“ |”&CHAR(10),2)

reptrowheight04

NOTE: After you add the formula, you might have to autofit the rows again, to see the effect. OR, select the spacing column, and turn Wrap Text off, then on again.

注意:添加公式后,可能必须再次自动调整行以查看效果。 或者,选择间距列,然后关闭“自动换行”,然后再次打开。

reptrowheight12

调整设置 (Adjust the Settings)

You can adjust the REPT formula, and the cell formatting, to control the row height. For example, change the number_times argument to 1, so the row height is shorter.

您可以调整REPT公式和单元格格式来控制行高。 例如,将number_times参数更改为1,因此行高较短。

reptrowheight05

Or, change the font to a smaller size, so there’s a little less white space.

或者,将字体更改为较小的字体,从而减少空白。

reptrowheight06

单元格上的图片 (Pictures Over Cells)

AlexJ sent me his REPT formula at the perfect time, because I found another need for it – setting a cell height for pictures.

AlexJ在最合适的时间向我发送了他的REPT公式,因为我发现还需要它-设置图片的像元高度。

In Excel, you can paste a picture onto a worksheet, but it floats over the sheet – it’s not really in a cell. If you want the pictures to move with the cell

在Excel中,您可以将图片粘贴到工作表上,但它会浮动在工作表上-并不是真正位于单元格中。 如果您希望图片随单元移动

  • make sure that the picture’s top left corner is inside the cell

    确保图片的左上角在单元格内
  • set its properties for “Move but don’t size with cells”

    将其属性设置为“移动但不随单元格调整大小”
reptrowheight09

If the pictures are properly positioned, they will sort with their row. But, if you do an Autofit on the row height, the picture height is ignored, and all the pictures can end up in a messy pile.

如果图片放置正确,它们将按行排序。 但是,如果对行高执行“自动调整”,则图片高度将被忽略,并且所有图片最终都会变成一团糟。

reptrowheight08

设置图片的行高 (Set Row Height for Pictures)

Instead of leaving the picture cells empty, use a REPT formula to set a minimum row height – I used 6 as the number_times argument in this table.

不要将图片单元格留空,而应使用REPT公式设置最小行高–我在表中使用6作为number_times参数。

reptrowheight07

Now I can autofit the rows, and they will never get shorter than the minimum height set by the REPT formula in the Picture column.

现在,我可以自动调整行,它们永远不会比“图片”列中REPT公式设置的最小高度短。

下载样本文件 (Download the Sample File)

You can download the sample file, to see how AlexJ’s technique works. Go to the AlexJ Sample Files page on my website, and in the Functions section, look for FN0001 – Set Minimum Row Height. The zipped file is in xlsx format, and does not contain macros.

您可以下载示例文件,以了解AlexJ的技术如何工作。 转到我网站上的AlexJ示例文件页面,然后在“功能”部分中查找FN0001 –设置最小行高 。 压缩文件为xlsx格式,不包含宏。

翻译自: https://contexturesblog.com/archives/2014/07/24/set-row-height-with-rept-function/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值