Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default 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
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default 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...
Reply
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
http://CannotDeleteFile.net - Cannot Delete File? Try Long Path ToolFilename is too long? Computer Complaining Your Filename Is Too Long? TheLong Path Tool Can Help While most people can go about their businessblissfully unaware of the Windo Max Loger Excel Discussion (Misc queries) 0 June 14th 11 04:30 PM
Long Long Long Nested If Function sed Excel Discussion (Misc queries) 4 December 9th 09 06:44 PM
Interrupting long calculations in Excel? Hi all, I am having a verylong calculation in Excel using VBA. Of course I know I can hit ESC orCTRL+BREAK to interrupt the VBA program. But I found due to too long runningprocess, the Excel window stop to LunaMoon Excel Discussion (Misc queries) 3 July 31st 08 04:47 PM
Clearing cells takes long, long time unclemuffin Excel Discussion (Misc queries) 9 August 17th 07 02:22 AM
Clearcontents takes long, long, time Fid[_2_] Excel Programming 3 August 15th 07 12:40 AM


All times are GMT +1. The time now is 01:42 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"