7

ポップアップ ボックスを使用して長い日付に x の日数を追加しようとしています。

Public Function AskForDeadlinePlus4() As String
    Dim strUserResponse As String

    strUserResponse = InputBox("Enter Validuntil Date: Add # of Days To Survey end date")
    strUserResponse = FormatDateTime(strUserResponse + I2, vbLongDate)
    ActiveSheet.Cells(2, 10).Value = strUserResponse 'the 2, 10 is the cell reference for J2 - row 2, column 10.

End Function

セル I2 の調査終了日。

これを実行すると、次のようになります(これを行う方法をグーグルで調べると疲れます)

4 + I2(ここでI2 = Friday, April 05, 2013) >> Wednesday, January 03, 1900

もちろん必要ですTuesday, April 09, 2013

ありがとう

4

3 に答える 3

17

機能を利用したことがありDateAddますか?

Sub DateExample()

Dim strUserResponse As String '## capture the user input'
Dim myDate As Date     '## the date you want to add to'
Dim numDays As Double  '## The number of days you want to add'


strUserResponse = InputBox("Enter Validuntil Date: Add # of Days To Survey end date")
numDays = InputBox("How many days to add?")
myDate = CDate(strUserResponse)

MsgBox DateAdd("d", numDays, myDate)


End Sub
于 2013-04-28T03:16:52.797 に答える