![]() |
Use of Today() and change data type
Hi all
How would I insert the date into a cell (programatically) then change its data type to text. Currently, when I open the file days later, of course, Excel populates the cells with the current date. My desired end result is subsequent openings will display the date the cell was originally populated. (Needs to stay the same always.) Does anyone have a better idea how to do this? I have the following With oExcel .Range("L1").Select .Selection.NumberFormat = "General" .ActiveCell.FormulaR1C1 = "WorkOrder" .Range("L2").Select .ActiveCell.FormulaR1C1 = z .Range("L3").Select .ActiveCell.FormulaR1C1 = z .Range("L2").Select .Selection.AutoFill Destination:=.Range("L2:L3"), Type:=xlFillDefault .Range("L2:L3").Select ' .Selection.AutoFill Destination:=.Range("L2:L99"), Type:=xlFillDefault .Selection.AutoFill Destination:=.Range("L2:L" & DATAcount + 1), Type:=xlFillDefault ' .Range("L2:L99").Select .Range("M1").Select .Selection.NumberFormat = "@" '"General" .ActiveCell.FormulaR1C1 = "DateRun" .Range("M2").Select .ActiveCell.FormulaR1C1 = "=TODAY()" .Range("M3").Select .ActiveCell.FormulaR1C1 = "=TODAY()" .Range("M2:M3").Select .Selection.AutoFill Destination:=.Range("M2:M" & DATAcount + 1), Type:=xlFillDefault ' .Range("M2:M99").Select ' .ActiveWindow.LargeScroll Down:=-2 ' .ActiveWindow.LargeScroll ToRight:=-1 .Range("N1").Select ' .ActiveWorkbook.Save .ActiveWorkbook.Close SaveChanges:=True End With Regards Dale |
Use of Today() and change data type
Dale
Range("G14") = Date inputs a static date = today -- steveB Remove "AYN" from email to respond "Dale" <D-Man wrote in message ... Hi all How would I insert the date into a cell (programatically) then change its data type to text. Currently, when I open the file days later, of course, Excel populates the cells with the current date. My desired end result is subsequent openings will display the date the cell was originally populated. (Needs to stay the same always.) Does anyone have a better idea how to do this? I have the following With oExcel .Range("L1").Select .Selection.NumberFormat = "General" .ActiveCell.FormulaR1C1 = "WorkOrder" .Range("L2").Select .ActiveCell.FormulaR1C1 = z .Range("L3").Select .ActiveCell.FormulaR1C1 = z .Range("L2").Select .Selection.AutoFill Destination:=.Range("L2:L3"), Type:=xlFillDefault .Range("L2:L3").Select ' .Selection.AutoFill Destination:=.Range("L2:L99"), Type:=xlFillDefault .Selection.AutoFill Destination:=.Range("L2:L" & DATAcount + 1), Type:=xlFillDefault ' .Range("L2:L99").Select .Range("M1").Select .Selection.NumberFormat = "@" '"General" .ActiveCell.FormulaR1C1 = "DateRun" .Range("M2").Select .ActiveCell.FormulaR1C1 = "=TODAY()" .Range("M3").Select .ActiveCell.FormulaR1C1 = "=TODAY()" .Range("M2:M3").Select .Selection.AutoFill Destination:=.Range("M2:M" & DATAcount + 1), Type:=xlFillDefault ' .Range("M2:M99").Select ' .ActiveWindow.LargeScroll Down:=-2 ' .ActiveWindow.LargeScroll ToRight:=-1 .Range("N1").Select ' .ActiveWorkbook.Save .ActiveWorkbook.Close SaveChanges:=True End With Regards Dale |
Use of Today() and change data type
With oExcel
.Range("L1").Value = "WorkOrder" .Range("L2").FormulaR1C1 = z .Range("L3").FormulaR1C1 = z .Range("L2").AutoFill Destination:=.Range("L2:L3"), Type:=xlFillDefault .Range("L2:L3").AutoFill Destination:=.Range("L2:L" & DATAcount + 1), Type:=xlFillDefault .Range("M1").Value = "DateRun" .Range("M2").Value = Format(Date, "dd mmm yyyy") .Range("M3").Value = Format(Date, "dd mmm yyyy") .Range("M2:M3").AutoFill Destination:=.Range("M2:M" & DATAcount + 1), Type:=xlFillDefault .ActiveWorkbook.Close SaveChanges:=True End With -- HTH Bob Phillips "Dale" <D-Man wrote in message ... Hi all How would I insert the date into a cell (programatically) then change its data type to text. Currently, when I open the file days later, of course, Excel populates the cells with the current date. My desired end result is subsequent openings will display the date the cell was originally populated. (Needs to stay the same always.) Does anyone have a better idea how to do this? I have the following With oExcel .Range("L1").Select .Selection.NumberFormat = "General" .ActiveCell.FormulaR1C1 = "WorkOrder" .Range("L2").Select .ActiveCell.FormulaR1C1 = z .Range("L3").Select .ActiveCell.FormulaR1C1 = z .Range("L2").Select .Selection.AutoFill Destination:=.Range("L2:L3"), Type:=xlFillDefault .Range("L2:L3").Select ' .Selection.AutoFill Destination:=.Range("L2:L99"), Type:=xlFillDefault .Selection.AutoFill Destination:=.Range("L2:L" & DATAcount + 1), Type:=xlFillDefault ' .Range("L2:L99").Select .Range("M1").Select .Selection.NumberFormat = "@" '"General" .ActiveCell.FormulaR1C1 = "DateRun" .Range("M2").Select .ActiveCell.FormulaR1C1 = "=TODAY()" .Range("M3").Select .ActiveCell.FormulaR1C1 = "=TODAY()" .Range("M2:M3").Select .Selection.AutoFill Destination:=.Range("M2:M" & DATAcount + 1), Type:=xlFillDefault ' .Range("M2:M99").Select ' .ActiveWindow.LargeScroll Down:=-2 ' .ActiveWindow.LargeScroll ToRight:=-1 .Range("N1").Select ' .ActiveWorkbook.Save .ActiveWorkbook.Close SaveChanges:=True End With Regards Dale |
All times are GMT +1. The time now is 07:38 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com