LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Adding date and time to cell programatically?


Hi all, i have been trying to check a cell that contains NOW() for a
time and populate another cell based on an evaluation of a formula with
a concatenation that looks like NOW().

I need to put a certain date AND a certain time in a cell but it can't
be text as the cell is used by the network for PI tag data retrival, as
you can see from the coe i have tried a number of things, the cell is
custom formatted to dd/mm/yyyy hh:mm.

Any ideas?



VBA Code:
--------------------


Sub Formula_Add()
Dim eformula, d As Date, MyTime, MyTime1
Application.ScreenUpdating = False
d = CDate(Format(Date, "dd/mm/yyyy")) - 1

MyTime = #3:45:00 AM#
MyTime1 = #5:45:00 PM#
MsgBox CDate(d)

eformula = "=IF(AND(MOD('Sheet1'!B1,1)TIMEVALUE(" & Chr(34) & "07:00" & Chr(34) & _
"),MOD('Sheet1'!B1,1)<TIMEVALUE(" & Chr(34) & "19:00" & Chr(34) & "))," & Chr(34) & "Days" & Chr(34) & _
"," & Chr(34) & "Nights" & Chr(34) & ")"

If Evaluate(eformula) = "Nights" Then
Sheets("Sheet1").Range("A1").Value = d & " " & MyTime 'TimeValue("05:45")
Else
'Sheets("Sheet1").Range("A1").Value = Format(Date, "dd/mm/yyyy") & " 17:45"
'Sheets("Sheet1").Range("A1").Value = Date - 1 & " 17:45"
Sheets("Sheet1").Range("A1").Value = CDate(d) & " 17:45"
End If

End Sub
--------------------


--
Simon Lloyd

Regards,
Simon Lloyd
'Excel Chat' (http://www.thecodecage.com/forumz/chat.php)
------------------------------------------------------------------------
Simon Lloyd's Profile: 1
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=186566

Excel Live Chat

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding Time to a Date Ludo Excel Programming 1 February 14th 08 05:19 PM
Adding a reference programatically Fred Excel Programming 10 April 29th 06 12:55 AM
Adding time to date-time formatted cell tawtrey(remove this )@pacificfoods.com Excel Discussion (Misc queries) 4 August 12th 05 10:53 PM
Adding a Control programatically Richard Buttrey Excel Programming 9 July 5th 05 08:34 AM
Adding a date and time Skip4t4 Excel Worksheet Functions 1 March 5th 05 05:37 PM


All times are GMT +1. The time now is 09:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"