Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default VBA Equivalent for Excel Function

I am looking for the VBA equivalent for the following function:

=isnumber(value(mid("Export20090224.xls",7,8)))

What I am trying to do is make sure that when the user saved the filename
that they entered the date properly as in 20090224 rather than 2009224. Maybe
this is a weak approach as I am just testing for the length more than
enything else. Can I get the date from the 'saved date' stamp pehaps?

If there is an even better way of doing this, then that would be great.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA Equivalent for Excel Function

Public Function GetDateName(dte As Date) As String
GetDateName = Format(dte, "YYYYMMDD")
End Function




"Bob Zimski" wrote:

I am looking for the VBA equivalent for the following function:

=isnumber(value(mid("Export20090224.xls",7,8)))

What I am trying to do is make sure that when the user saved the filename
that they entered the date properly as in 20090224 rather than 2009224. Maybe
this is a weak approach as I am just testing for the length more than
enything else. Can I get the date from the 'saved date' stamp pehaps?

If there is an even better way of doing this, then that would be great.

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default VBA Equivalent for Excel Function

Hi Bob,

Dim strFileName As String

strFileName = "Export" & Format(Date, "yyyymmdd") & ".xls"

MsgBox strFileName 'For testing only

--
Regards,

OssieMac


"Bob Zimski" wrote:

I am looking for the VBA equivalent for the following function:

=isnumber(value(mid("Export20090224.xls",7,8)))

What I am trying to do is make sure that when the user saved the filename
that they entered the date properly as in 20090224 rather than 2009224. Maybe
this is a weak approach as I am just testing for the length more than
enything else. Can I get the date from the 'saved date' stamp pehaps?

If there is an even better way of doing this, then that would be great.

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default VBA Equivalent for Excel Function

You can test this way (where the variable FileName is assumed to hold the
filename entered by the user)...

If FileName Like "*########.xls" Then
MsgBox "The shape of the filename appears to be correct"
Else
MsgBox "Something appears to be wrong with the filename"
End If

If the

--
Rick (MVP - Excel)


"Bob Zimski" wrote in message
...
I am looking for the VBA equivalent for the following function:

=isnumber(value(mid("Export20090224.xls",7,8)))

What I am trying to do is make sure that when the user saved the filename
that they entered the date properly as in 20090224 rather than 2009224.
Maybe
this is a weak approach as I am just testing for the length more than
enything else. Can I get the date from the 'saved date' stamp pehaps?

If there is an even better way of doing this, then that would be great.

Thanks


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default VBA Equivalent for Excel Function

Hi again Bob,

Not sure if that code needed any more explanation but to save you time just
in case.

Date in VBA is today's date.

You can use a date variable in place of Date. The following code assigns
today's date to a date variable and uses the date variable. You could assign
any valid date to a date variable to use for the file name.


Dim dateToDay As Date
Dim strFileName As String

dateToDay = Date 'Today's date

strFileName = "Export" & Format(dateToDay, "yyyymmdd") & ".xls"

MsgBox strFileName 'For testing only

--
Regards,

OssieMac


"Bob Zimski" wrote:

I am looking for the VBA equivalent for the following function:

=isnumber(value(mid("Export20090224.xls",7,8)))

What I am trying to do is make sure that when the user saved the filename
that they entered the date properly as in 20090224 rather than 2009224. Maybe
this is a weak approach as I am just testing for the length more than
enything else. Can I get the date from the 'saved date' stamp pehaps?

If there is an even better way of doing this, then that would be great.

Thanks

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
NZ function equivalent in Excel jg Excel Worksheet Functions 7 April 21st 23 05:15 PM
Countifs function equivalent for Excel 2002 (XP) Task Database Nightmare Excel Worksheet Functions 1 January 5th 10 07:04 PM
Lotus 123 @nsum function equivalent in excel(?) marke54805 Excel Worksheet Functions 10 October 15th 08 08:28 AM
Excel equivalent to Eval function PatrickS Excel Programming 1 August 15th 07 11:54 AM
What is the Excel equivalent of the CELL function? JP Excel Worksheet Functions 8 September 5th 06 12:49 AM


All times are GMT +1. The time now is 02:03 AM.

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

About Us

"It's about Microsoft Excel"