PC Review


Reply
Thread Tools Rate Thread

Date from string

 
 
Robert_L_Ross
Guest
Posts: n/a
 
      24th Oct 2008
I have a unique problem. When I export a report from a program, the dates
are formatted as mm/dd/yyyy:
09/01/2008

When other users export the same report from the same program, the dates are
formatted as m/d/yyyy:
9/1/2008

I don't know if it's an Excel issue, Windows or even the source program, but
that's not important.

The export has cell B3 with this value (on my machine):
09/01/2008 to 09/30/2008

When I go into a macro with the following line:
Message = MsgBox(InStr(1, "B3", " to "), vbOKOnly, "test")
I get a dialog box with "0"

This makes no sense...when I use the Find function in the spreadsheet it
works:
=FIND(" to ",B3,1) Returns 11

I'm trying to find a way in the VB code to account for the different date
formats...if I can find where " to " starts, I can trim the value. I need
the value to determine a name for the file based on it's contents.

Thanks!!
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      24th Oct 2008
"B3" is the text B3--not what is in some worksheet in cell B3.

Message = MsgBox(InStr(1, worksheets("sheet999").range("B3").value, " to "), _
vbOKOnly, "test")

You may have to include the workbook that that worksheet belongs to, too.

Robert_L_Ross wrote:
>
> I have a unique problem. When I export a report from a program, the dates
> are formatted as mm/dd/yyyy:
> 09/01/2008
>
> When other users export the same report from the same program, the dates are
> formatted as m/d/yyyy:
> 9/1/2008
>
> I don't know if it's an Excel issue, Windows or even the source program, but
> that's not important.
>
> The export has cell B3 with this value (on my machine):
> 09/01/2008 to 09/30/2008
>
> When I go into a macro with the following line:
> Message = MsgBox(InStr(1, "B3", " to "), vbOKOnly, "test")
> I get a dialog box with "0"
>
> This makes no sense...when I use the Find function in the spreadsheet it
> works:
> =FIND(" to ",B3,1) Returns 11
>
> I'm trying to find a way in the VB code to account for the different date
> formats...if I can find where " to " starts, I can trim the value. I need
> the value to determine a name for the file based on it's contents.
>
> Thanks!!


--

Dave Peterson
 
Reply With Quote
 
Robert_L_Ross
Guest
Posts: n/a
 
      24th Oct 2008
Dave,

Thanks...after I posted that and just before I left work I remembered I
needed to specify the cell value...in this case I didn't need to specify the
sheet name since I'm looking at the active sheet when the macro runs.

Thanks!

"Dave Peterson" wrote:

> "B3" is the text B3--not what is in some worksheet in cell B3.
>
> Message = MsgBox(InStr(1, worksheets("sheet999").range("B3").value, " to "), _
> vbOKOnly, "test")
>
> You may have to include the workbook that that worksheet belongs to, too.
>
> Robert_L_Ross wrote:
> >
> > I have a unique problem. When I export a report from a program, the dates
> > are formatted as mm/dd/yyyy:
> > 09/01/2008
> >
> > When other users export the same report from the same program, the dates are
> > formatted as m/d/yyyy:
> > 9/1/2008
> >
> > I don't know if it's an Excel issue, Windows or even the source program, but
> > that's not important.
> >
> > The export has cell B3 with this value (on my machine):
> > 09/01/2008 to 09/30/2008
> >
> > When I go into a macro with the following line:
> > Message = MsgBox(InStr(1, "B3", " to "), vbOKOnly, "test")
> > I get a dialog box with "0"
> >
> > This makes no sense...when I use the Find function in the spreadsheet it
> > works:
> > =FIND(" to ",B3,1) Returns 11
> >
> > I'm trying to find a way in the VB code to account for the different date
> > formats...if I can find where " to " starts, I can trim the value. I need
> > the value to determine a name for the file based on it's contents.
> >
> > Thanks!!

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      24th Oct 2008
If you have a column of cells that contain this kind of information:
09/01/2008 to 09/30/2008

You could insert a column (or two) and use data|text to columns to parse the
string. You'll be able to specify the format for each date field (mdy), too.

And if you need a macro, you could record one when you do it manually to get the
syntax.

Robert_L_Ross wrote:
>
> Dave,
>
> Thanks...after I posted that and just before I left work I remembered I
> needed to specify the cell value...in this case I didn't need to specify the
> sheet name since I'm looking at the active sheet when the macro runs.
>
> Thanks!
>
> "Dave Peterson" wrote:
>
> > "B3" is the text B3--not what is in some worksheet in cell B3.
> >
> > Message = MsgBox(InStr(1, worksheets("sheet999").range("B3").value, " to "), _
> > vbOKOnly, "test")
> >
> > You may have to include the workbook that that worksheet belongs to, too.
> >
> > Robert_L_Ross wrote:
> > >
> > > I have a unique problem. When I export a report from a program, the dates
> > > are formatted as mm/dd/yyyy:
> > > 09/01/2008
> > >
> > > When other users export the same report from the same program, the dates are
> > > formatted as m/d/yyyy:
> > > 9/1/2008
> > >
> > > I don't know if it's an Excel issue, Windows or even the source program, but
> > > that's not important.
> > >
> > > The export has cell B3 with this value (on my machine):
> > > 09/01/2008 to 09/30/2008
> > >
> > > When I go into a macro with the following line:
> > > Message = MsgBox(InStr(1, "B3", " to "), vbOKOnly, "test")
> > > I get a dialog box with "0"
> > >
> > > This makes no sense...when I use the Find function in the spreadsheet it
> > > works:
> > > =FIND(" to ",B3,1) Returns 11
> > >
> > > I'm trying to find a way in the VB code to account for the different date
> > > formats...if I can find where " to " starts, I can trim the value. I need
> > > the value to determine a name for the file based on it's contents.
> > >
> > > Thanks!!

> >
> > --
> >
> > Dave Peterson
> >


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date string problem in query string when posting back =?Utf-8?B?SnVsaWEgQg==?= Microsoft ASP .NET 5 29th Aug 2007 03:08 PM
How to Change Input String Data to Date/Time Date!! =?Utf-8?B?U2lkeg==?= Microsoft Access Form Coding 3 12th Apr 2006 07:38 PM
How to convert user-defined custom format date string to date value abcabcabc Microsoft VB .NET 1 19th Aug 2005 12:31 PM
Date string and Charater string syntax =?Utf-8?B?aWhvbGRlcg==?= Microsoft Access VBA Modules 4 18th Feb 2005 10:09 PM
Using Date Form Field data in Outputto Filename (a date to string chanbge needed)? Rob Oldfield Microsoft Access Form Coding 3 4th Jan 2005 08:06 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:44 AM.