• 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.

merge data from input box and selected cell

nanobuns

New Member
Hi,

I have a given data see below:

Time
02:00:00
03:00:00
04:00:00
05:00:00
06:00:00
07:00:00

Is there any fastest way to input a date before each time?

Thanks,

nano
 
Hi Nano..

How About..
Copy the date.. from cell D1(Imaginary cell)
and paste all over the range.. as paste Special Add..
Alt E S V D

Dont forget to change the format (dd-mm-yyyy hh:mm:ss) of the Range after Paste..
 
Hi Debraj,

Thanks for the reply.
Anyways.
I was able to append the date with the time using the below code. But in order for me to have the same output i have to format the cell to text, the thing is after doing that i cannot compute the difference of the time since its in text format. If i format the cell to (dd-mm-yyyy hh:mm:ss) the time changes to decimal number everytime i append the date before the time. Is there any other way to do this?

Dim c As Range

Dim idate As String

idate = InputBox("Enter Date", "Input data")
For Each c In Selection
If c.Value <> "" Then c.Value = idate & " / " & c.Value
Next
End Sub

thanks,

nano
 
Hi ,

Try this :
Code:
Sub Add_Date()
    Dim c As Range
    Dim idate As Long

    On Error GoTo error_handler:
    idate = Application.InputBox("Enter Date", "Input data", , , , , , 1)
    For Each c In Selection
        If c.Value <> "" Then c.Value = idate + c.Value
    Next
    On Error GoTo 0
    Exit Sub
error_handler:
       MsgBox "Invalid date !", vbCritical
End Sub
Narayan
 
Back
Top