我知道之前已经提出这个问题,但我没有找到一个好的答案。我无法进行Windows更新,因为此表单用于全国各地的多台计算机上。
我有24个默认隐藏的复选框,它们会根据组合框值变为可见。如果我保存文件时隐藏了复选框,一旦打开它,所有复选框都将位于一个位置(而不是它们的位置)。如果我保存它并且复选框可见,那么我打开它一切都很好。
这是不好的 这是一个很好的
我让它工作的唯一方法是,如果我保存它并隐藏所有复选框,那么当工作簿打开时我隐藏它们。如果用户没有正确保存,这可能是一个问题。 喜欢这个
'if the row the row is hidden then the 2 checkboxes on this row are hidden too
ActiveSheet.Rows("54:101").Hidden = False
'Hide rows 54 to 101
ActiveSheet.ComboBox2.Value = ""
ActiveSheet.ComboBox3.Value = ""
我尝试更改复选框的对象定位属性,但似乎必须Move but don't size with cells
才能使用
答案 0 :(得分:2)
Dim rng As Range
Set rng = ActiveSheet.Range("H65")
With ActiveSheet.OLEObjects("CheckBox223")
.Top = rng.Top
.Left = rng.Left
.Width = rng.Width
.Height = rng.RowHeight
End With
Set rng = ActiveSheet.Range("J65")
With ActiveSheet.OLEObjects("CheckBox224")
.Top = rng.Top
.Left = rng.Left
.Width = rng.Width
.Height = rng.RowHeight
End With
Set rng = ActiveSheet.Range("H69")
With ActiveSheet.OLEObjects("CheckBox221")
.Top = rng.Top
.Left = rng.Left
.Width = rng.Width
.Height = rng.RowHeight
End With
Set rng = ActiveSheet.Range("J69")
With ActiveSheet.OLEObjects("CheckBox222")
.Top = rng.Top
.Left = rng.Left
.Width = rng.Width
.Height = rng.RowHeight
End With
Set rng = ActiveSheet.Range("H73")
With ActiveSheet.OLEObjects("CheckBox219")
.Top = rng.Top
.Left = rng.Left
.Width = rng.Width
.Height = rng.RowHeight
End With
Set rng = ActiveSheet.Range("J73")
With ActiveSheet.OLEObjects("CheckBox220")
.Top = rng.Top
.Left = rng.Left
.Width = rng.Width
.Height = rng.RowHeight
End With