背景资料
我有一个输入框,用于从我的用户那里获取日期以处理子过程。
问题
cells(1, columns.count)
invalid qualifier
你能解释一下原因吗?Sub functionLoop()
Dim Nextoffday As Date
Dim i As Integer
Dim selectionRow As String
Nextoffday = Application.InputBox(prompt:="Please select the second off day.", Title:="Pick second off day", Type:=8)
For i = 1 To 30
If AFPDAY(Nextoffday + i) <> "" Then
ThisWorkbook.Worksheets(1).Cells(1, Columns.Count).End(xlToLeft).Offset(0, 1) = AFPDAY(Nextoffday + i)
End If
Next i
End Sub
答案 0 :(得分:1)
要查找所选单元用户的地址,请尝试使用以下代码:
Dim Nextoffday As Range 'defining Nextoffday as range instead of date
Set Nextoffday = Application.InputBox(prompt:="Please select the second off day.", Title:="Pick second off day", Type:=8) 'setting it to the user selected cell
MsgBox Nextoffday.Address ' .address will return the address of the cell selected by user
MsgBox Format(Nextoffday.Value, "mm.dd.yyyy") 'will convert the value in date format
Selection.Address
将返回活动选定单元格的单元格引用。