|
我在VBA中设置行高,列宽,在网上找到了行高的设置方法,其中行高用数字代表,可以执行。
后我根据它修改为列宽设置,但执行时报错,提示A变量未定义,列不是用字母表示吗?请问
ActiveSheet.Cells(a, a).ColumnWidth = 12 这句错在哪?
Private Sub Worksheet_Activate()
ActiveSheet.Cells.RowHeight = 43
ActiveSheet.Cells(1, 1).RowHeight = 12
ActiveSheet.Cells(3, 3).RowHeight = 25
ActiveSheet.Cells(4, 4).RowHeight = 25
ActiveSheet.Cells(19, 19).RowHeight = 25
ActiveSheet.Cells(20, 20).RowHeight = 25
ActiveSheet.Cells(21, 21).RowHeight = 25
ActiveSheet.Cells(22, 22).RowHeight = 25
ActiveSheet.Cells.ColumnWidth = 25
ActiveSheet.Cells(a, a).ColumnWidth = 12
End Sub
本帖最后由 hwc2ycy 于 2012-8-23 21:41 编辑
字母用""括上。
ActiveSheet.Cells(1, “a”).ColumnWidth = 12
行的话可以定义一个长整形变量,或者用数字表示,这个不需要用双引号括。
列的话可以定义一个STRING变量,或者用字母表示(局限性大,在26以内的话尚可,得用双引号括起来)
|
|