• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Get user input via message box and update the range of cell in excel using macro

redvelvet

New Member
Hi All,
I need to create a macro to get the input from user. Here is the example: i want user to input the date and then update date value in all cell in column P

Could you please share with me how to achieve this?
I have a simple macro and i want to include this step in my mini project.

I hope you can help me. Thanks very much
 
Ah, never considered Mac user. I never had to deal with them personally.

See attached for Date Picker I've used before for backward compatibility. It requires you to have hidden sheet named "Calendar" for it to work. You can modify portion below to suite your needs (to adjust output cell).

For the life of me, can't remember where I found original code that I modified...

Code:
'~~> Ok Button
Private Sub CommandButton53_Click()
    If TextBox1.Value <> "" Then
        ThisWorkbook.Sheets("Sheet1").Cell(2, 1) = TextBox1.Value
    End If
    Unload UserForm1
End Sub

You can easily export and import the module to another workbook as needed.
 

Attachments

  • DatePicker.xlsm
    34.9 KB · Views: 15
Ah, that's unfortunate.
If all Date Value is same for P column and assuming P1 has the header...
Code:
Dim lRow As Long
Dim dRange As Range
lRow = ActiveSheet.Range("P" & Rows.Count).End(xlUp).Row
Set dRange = ActiveSheet.Range("P2:P" & lRow)

dString = Application.InputBox("Enter A Date")
For Each Cell In dRange
    If isDate(dString) Then
        iDate = DateValue(dString)
        Cell.Value = iDate
    Else
        MsgBox "Invalid Date"
    End If
Next
End Sub

Adjust range as needed.
 
Back
Top