PC Review


Reply
Thread Tools Rate Thread

Date formated as text

 
 
Karen53
Guest
Posts: n/a
 
      18th Jun 2008
Hi,

I have cells which contain text. The cells are formated as text. However
the text in these cells can appear to be a date even though they are not, for
example 3-11-09. How do I keep the date formated as text error form
happening and erroring out my code? I need it to disregard that it looks
like a date and just treat it like text.

If MainPagepg.Range("BD" & Newrow - 1) = "" Then
ShNumber = Firstpg.Index
Else
AfterShName = MainPagepg.Range("BD" & Newrow - 1).Value
ShNumber = Sheets(AfterShName).Index
End If

CAMMaster.Copy After:=Sheets(ShNumber)
--
Thanks for your help.
Karen53
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      18th Jun 2008
How did you declare AfterShName?

Dim AfterShName as String
or
Dim AfterShName as Variant 'or not declared???

If you used "as string", I would have guessed that your code would work.

But in either case, this may work (I didn't test it):
ShNumber = Sheets(cstr(AfterShName)).Index



Karen53 wrote:
>
> Hi,
>
> I have cells which contain text. The cells are formated as text. However
> the text in these cells can appear to be a date even though they are not, for
> example 3-11-09. How do I keep the date formated as text error form
> happening and erroring out my code? I need it to disregard that it looks
> like a date and just treat it like text.
>
> If MainPagepg.Range("BD" & Newrow - 1) = "" Then
> ShNumber = Firstpg.Index
> Else
> AfterShName = MainPagepg.Range("BD" & Newrow - 1).Value
> ShNumber = Sheets(AfterShName).Index
> End If
>
> CAMMaster.Copy After:=Sheets(ShNumber)
> --
> Thanks for your help.
> Karen53


--

Dave Peterson
 
Reply With Quote
 
Karen53
Guest
Posts: n/a
 
      18th Jun 2008
Hi Dave,

Yes, AfterShName was declared as a string. If the cell is in a general
format, Excel assumes it is a date. So, I changed the cell format to Text.
Then Excel indicates an error that the cell contains a date formated as text.

So far Cstr seems to be working. I'm still testing.

Thanks for your help!
--
Thanks for your help.
Karen53


"Dave Peterson" wrote:

> How did you declare AfterShName?
>
> Dim AfterShName as String
> or
> Dim AfterShName as Variant 'or not declared???
>
> If you used "as string", I would have guessed that your code would work.
>
> But in either case, this may work (I didn't test it):
> ShNumber = Sheets(cstr(AfterShName)).Index
>
>
>
> Karen53 wrote:
> >
> > Hi,
> >
> > I have cells which contain text. The cells are formated as text. However
> > the text in these cells can appear to be a date even though they are not, for
> > example 3-11-09. How do I keep the date formated as text error form
> > happening and erroring out my code? I need it to disregard that it looks
> > like a date and just treat it like text.
> >
> > If MainPagepg.Range("BD" & Newrow - 1) = "" Then
> > ShNumber = Firstpg.Index
> > Else
> > AfterShName = MainPagepg.Range("BD" & Newrow - 1).Value
> > ShNumber = Sheets(AfterShName).Index
> > End If
> >
> > CAMMaster.Copy After:=Sheets(ShNumber)
> > --
> > Thanks for your help.
> > Karen53

>
> --
>
> 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
Convert and sort date originally formated as text Cagney Microsoft Access Queries 3 25th Jan 2011 02:30 AM
date formated as date showing as number JR Microsoft Excel Misc 2 29th Oct 2008 08:48 PM
Excel SHOULD NOT AUTO-CHANGE formated text fields to DATE FIELDS! =?Utf-8?B?UFNTU0Q=?= Microsoft Excel Worksheet Functions 2 8th Aug 2006 09:31 PM
How do I convert a number formated as a date to text in Excel? =?Utf-8?B?QnJvdGhlck5vdg==?= Microsoft Excel Misc 5 2nd Mar 2005 03:51 PM
text is automatically formated as date! Emski27 Microsoft Excel Misc 1 6th Aug 2004 09:40 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:17 PM.