在使用VBA跟踪部分列的Excel模板中创建变量 [英] Create variables in Excel template that track section columns using VBA
本文介绍了在使用VBA跟踪部分列的Excel模板中创建变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
每当我想向模板添加新列时,需要更改一些值,以保持按钮对齐。
Whenever I want to add new columns to the template a number of values need to be changed in order to keep 'push buttons' aligned.
Property Get slp_hide_col() As String
slp_hide_col = "L:T"
End Property
*Seperate from the above code*
Private Sub SLP_Config_Click()
With Columns(slp_hide_col)
.Select
.EntireColumn.Hidden = Not .EntireColumn.Hidden
End With
End Sub
我想将slp_hide_col移动到每列的值添加。
任何事情都有助于感谢
I wanted to shift the slp_hide_col by a value of each column added. Anything would help thanks
推荐答案
您可以为创建命名范围L:T
。添加新列后,命名范围班。
You can create named range for L:T
. After adding new columns, named range shifts.
然后可以使用如下:
Property Get slp_hide_col() As String
slp_hide_col = "myNamedRange"
End Property
,然后将列(slp_hide_col)
更改为范围(slp_hide_col)
:
Public Sub SLP_Config_Click()
With Range(slp_hide_col)
.Select
.EntireColumn.Hidden = Not .EntireColumn.Hidden
End With
End Sub
这篇关于在使用VBA跟踪部分列的Excel模板中创建变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文