Add x number of days to a date with vba in excel

后端 未结 3 1236
时光说笑
时光说笑 2020-12-19 07:38

I am tring to add x number of days to a Long date with a pop up box.

Public Function AskForDeadlinePlus4() As String
    Dim strUserResponse As String

    s         


        
3条回答
  •  太阳男子
    2020-12-19 07:45

    Have you used the DateAdd function?

    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
    

提交回复
热议问题