我希望在使用Application InputBox后得到选择的列号,但它总是有错误。
这是我到目前为止所做的:
Dim cln1 as Integer
selection1 = Application.InputBox(prompt:="Please select the fist column.", Title:="First Column")
cln1 = selection1.Cells(1, 1).Column
debug.print(cln1)
我不确定为什么这不起作用。有人能告诉我如何纠正这个问题吗?谢谢!
答案 0 :(得分:1)
这应该可以解决问题,把它放在你的子目录中:
Dim selection1 As Range
Dim cln1 As Integer
Set selection1 = Application.InputBox(Prompt:="Please select the fist column.", Title:="First Column", Type:=8)
cln1 = selection1.Cells(1, 1).Column
MsgBox cln1
类型:= 8让它知道selection1是一个范围对象