从input框中获取行和列
背景信息
我有一个input框来从我的用户得到一个date来处理子程序。
问题
- 我无法从input的值中获取行和列。
- 我如何返回结果在用户select的行而不是固定点的
cells(1, columns.count)
- 我尝试使用.address来查找行和列。 但是它返回
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
要find所选单元格用户的地址,请尝试使用以下代码:
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
将返回活动选定单元的单元格引用。