ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How Can I conver date i.e 18/11/2005 to 18112005.? (https://www.excelbanter.com/excel-programming/345951-how-can-i-conver-date-i-e-18-11-2005-18112005-a.html)

Manish Patel

How Can I conver date i.e 18/11/2005 to 18112005.?
 
Hi

I am doing one Pruchase Order form in Excel.

I want to creat the PO number as if date being Displayed in regular number.
i.e 18/11/2005 as if 18112005 and than followed by "-" and increasing value.

If I will open and print off 5 times in a day. The last number has to be
18112005-5.

Is there anybody can help me on it.

Kind Regards

Manish



chijanzen

How Can I conver date i.e 18/11/2005 to 18112005.?
 
Manish :

reference Workbook_BeforePrint

add this code to Thisworkbook

if range("A1") is empty


'Thisworkbook
Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Range("A1") = "" Then
n = 1
Else
s = VBA.Split(Range("A1"), "-")
n = s(1) + 1
End If
Range("A1") = VBA.Format(Date, "ddmmyy") & "-" & n
End Sub



--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Manish Patel" wrote:

Hi

I am doing one Pruchase Order form in Excel.

I want to creat the PO number as if date being Displayed in regular number.
i.e 18/11/2005 as if 18112005 and than followed by "-" and increasing value.

If I will open and print off 5 times in a day. The last number has to be
18112005-5.

Is there anybody can help me on it.

Kind Regards

Manish




All times are GMT +1. The time now is 03:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com