我需要在Excel组合框中更改字体大小,因为默认字体太小。有没有办法做到这一点?
这是我用于宏的代码:
Option Explicit
Sub DropDown4_Change()
Dim comboValue As String
Dim Key1ColumnIndex As Integer
Dim Key2ColumnIndex As Integer
Dim Index As Integer
Dim comboName As String
Dim comboName2 As String
Dim comboID As Integer
'You can get the name by doing something like this in the immediate window: "? Sheet1.Shapes(1).OLEFormat.Object.Name"
For Index = 1 To ActiveSheet.Shapes.Count
comboName = ActiveSheet.Shapes(Index).OLEFormat.Object.Name
If InStr(comboName, "Drop") > 0 Then
'MsgBox InStr(comboName, "Drop")
comboName2 = comboName
comboID = Index
End If
Next
comboValue = ActiveSheet.Shapes(comboID).ControlFormat.List(ActiveSheet.Shapes(comboID).ControlFormat.ListIndex)
Select Case comboValue
Case "By Keyphrase"
Key1ColumnIndex = 18
Key2ColumnIndex = 19
Case "By Region"
Key1ColumnIndex = 19
Key2ColumnIndex = 18
Case "Default"
Key1ColumnIndex = 1
Key2ColumnIndex = 1
End Select
Range("DataValues").sort Key1:=Range("DataValues").Cells(1, Key1ColumnIndex), _
Order1:=xlAscending, Header:=xlNo, DataOption1:=xlSortNormal, _
Key2:=Range("DataValues").Cells(1, Key2ColumnIndex), order2:=xlAscending
End Sub
谢谢。
答案 0 :(得分:2)
无法完成
没有格式化表单下拉列表的字体大小 - 甚至是以编程方式。如果这是绝对要求,则必须将其切换为activeX控件。
答案 1 :(得分:0)
正如@Alain 所说,您根本无法以干净的方式进行操作,或者您必须使用 ActiveX 控件。
但这里也有一个解决方法。 通过编程,您可以临时缩放工作表,使数据验证字号显得更大。
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$2" Then
ActiveWindow.Zoom = 120
Else
ActiveWindow.Zoom = 100
End If
End Sub
积分和更多详情:https://www.contextures.com/xldataval08.html#zoommacro