![]() |
Leading Zero for Long
Hello:
I am using an inputbox to set a variable to a specific number and need to preserve the leading zero because it affects an address reference to a file I am trying to download. It uses 2 digits for month and day, with a leading zero for single digit months/days. The macro prompts the User for the month they want to pull the report for, then the day. Your help is most appreciated. Steven |
Leading Zero for Long
An input box is text. so the best thing to do is to convert the date to
microsfot serial date and then format the date however you want. the user can input the date in any vaid date format they want. For example MyDate = inputbox("enter Date : " SerialDate = DateValue(MyDate) FormatDate = Format(SerialDate,"MMDDYY") or for 4 digit year FormatDate = Format(SerialDate,"MMDDYYYY") or FormatDate = Format(SerialDate,"MMMM DD, YYYY") MM = 2 Digit month MMM = 3 Character abbreviated Month MMMM = Full Name of Month spelled out. " wrote: Hello: I am using an inputbox to set a variable to a specific number and need to preserve the leading zero because it affects an address reference to a file I am trying to download. It uses 2 digits for month and day, with a leading zero for single digit months/days. The macro prompts the User for the month they want to pull the report for, then the day. Your help is most appreciated. Steven |
Leading Zero for Long
I hope this helps
Sub Get_MnDt() Dim sMonth, sDate As Integer sMonth = InputBox("Enter the month in numeeral (mm) format") sDate = InputBox("Enter the date in numeeral (dd) format") MsgBox "Output String = " & Format(sMonth, "00") & Format(sDate, "00") & vbNewLine & _ "Use the code : Format(sMonth, " & Chr(34) & "00" & Chr(34) & ") & Format(sDate, " & Chr(34) & "00" & Chr(34) & ") " End Sub - selva v pasupathy for more codes and examples visit http://socko.wordpress.com... |
Leading Zero for Long
On Oct 1, 2:36*pm, Joel wrote:
An input box is text. *so the best thing to do is to convert the date to microsfot serial date and then format the date however you want. *the user can input the date in any vaid date format they want. *For example MyDate = inputbox("enter Date : " SerialDate = DateValue(MyDate) FormatDate = Format(SerialDate,"MMDDYY") or for 4 digit year FormatDate = Format(SerialDate,"MMDDYYYY") or FormatDate = Format(SerialDate,"MMMM DD, YYYY") MM = 2 Digit month MMM = 3 Character abbreviated Month MMMM = Full Name of Month spelled out. " wrote: Hello: I am using an inputbox to set a variable to a specific number and need to preserve the leading zero because it affects an address reference to a file I am trying to download. It uses 2 digits for month and day, with a leading zero for single digit months/days. The macro prompts the User for the month they want to pull the report for, then the day. Your help is most appreciated. Steven Hi Joel: The only reason I did it that way is because I need it formatted YYYYMMDD. I also need to loop for a variable number of times, essentially for every day in the date range. This is only intended to be used for up to 1 full month. But it could also be used for as little as 1 day. My thought was to get the user to indicate the start date and end date, then use the End Date to determine how many times the loop is running. It is downloading CSV files from a server that generates one every day, but does not have functionality to produce a consolidated report for the entire month. We need the reports, but it is a huge time waster to download them manually. The files are named using the date format YYYYMMDD. Thoughts? Steven |
All times are GMT +1. The time now is 04:47 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com