vba 如何更改 Excel 下拉列表中的字体大小和颜色?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13380025/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 14:25:04  来源:igfitidea点击:

How do I change the font size and color in an Excel Drop Down List?

excelexcel-vbavba

提问by Christopher Leach

I was wondering if its possible to Style a Drop Down List in Excel. The text is rather small and has no styling and I was wondering if the drop down list styling could be changed?

我想知道是否可以在 Excel 中设置下拉列表的样式。文本很小,没有样式,我想知道是否可以更改下拉列表样式?

What would actually make sense is if the drop down list items copied the same styling as its source cells, i.e. alternating background colour of cells, font, size, etc. Or even the copying of the style of the validation cell itself!?

如果下拉列表项复制与其源单元格相同的样式,即单元格的交替背景颜色、字体、大小等,或者甚至复制验证单元格本身的样式,那么实际上有意义的是什么!?

Is there any way to change this using VBA or any other 3rd party method?

有什么办法可以使用 VBA 或任何其他 3rd 方方法来改变它?

采纳答案by Jon Crowell

Unfortunately, you can't change the font size or styling in a drop-down list that is created using data validation.

不幸的是,您无法在使用数据验证创建的下拉列表中更改字体大小或样式。

You can style the text in a combo box, however. Follow the instructions here: Excel Data Validation Combo Box

但是,您可以在组合框中设置文本样式。按照此处的说明进行操作:Excel 数据验证组合框

回答by Peter Tashkoff

You cannot change the default but there is a codeless workaround.

您无法更改默认值,但有一个无代码的解决方法。

Select the whole sheet and change the font size on your data to something small, like 10 or 12. When you zoom in to view the data you will find that the drop down box entries are now visible.

选择整个工作表并将数据上的字体大小更改为较小的字体大小,例如 10 或 12。当您放大查看数据时,您会发现下拉框条目现在可见。

To emphasize, the issue is not so much with the size of the font in the drop down, it is the relative size between drop down and data display font sizes.

需要强调的是,问题不在于下拉中的字体大小,而是下拉和数据显示字体大小之间的相对大小。

回答by Kamolga

I work on 60-70% zoom vue and my dropdown are unreadable so I made this simple code to overcome the issue

我在 60-70% 缩放 vue 上工作,我的下拉菜单不可读,所以我编写了这个简单的代码来解决这个问题

Note that I selected first all my dropdown lsts (CTRL+mouse click), went on formula tab, clicked "define name" and called them "ProduktSelection"

请注意,我首先选择了我所有的下拉列表(CTRL+鼠标单击),进入公式选项卡,单击“定义名称”并将它们称为“ProduktSelection”

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim KeyCells As Range
Set KeyCells = Range("ProduktSelection")
    If Not Application.Intersect(KeyCells, Range(Target.Address)) _
           Is Nothing Then

ActiveWindow.Zoom = 100

End If

End Sub

I then have another sub

然后我有另一个子

Private Sub Worksheet_Change(ByVal Target As Range) 

where I come back to 65% when value is changed.

当价值改变时,我会回到 65%。

回答by Billy Bob

Try making the whole sheet font size smaller. Then zoom and save. Make a practice sheet first because it really screws everything up.

尝试将整个工作表的字体变小。然后缩放并保存。先做一个练习表,因为它真的把一切都搞砸了。

回答by TRaggsy

I created a custom view that is at 100%. Use the dropdowns then click to view page layout to go back to a smaller view.

我创建了一个 100% 的自定义视图。使用下拉菜单,然后单击查看页面布局以返回到较小的视图。