PC Review


Reply
Thread Tools Rate Thread

capture only part of inputBox or of cell contents

 
 
=?Utf-8?B?SkNJcmlzaA==?=
Guest
Posts: n/a
 
      20th Oct 2006
Help. In inputBox the user enters a date (not usually the current date) for a
month for which he wants to enter data. This is stored in the variable
"userMonth" and entered into Range("F1"). I then use contents of F1 in a
Find method to select a cell (labled mmm) into which to paste the entered
data.

My code checks inputBox entry for a valid date. If entry is valid (say,
mmm,yy), here's the rub: I need to use only the mmm part in the Find method.
Is it possible to capture only the mmm part of the entry or alternatively to
retrieve only the mmm part from F1? Format (Date,"mmm") doesn't work here
because the date may not be the current date. I know that I could have the
user enter only the mmm in the inputBox but then I can't check that the entry
is a valid date (at least I don't think I can).
 
Reply With Quote
 
 
 
 
=?Utf-8?B?SmltIFRob21saW5zb24=?=
Guest
Posts: n/a
 
      20th Oct 2006
Give this a whirl...

MsgBox Format(CDate(InputBox("Enter a Date:")), "mmm")
--
HTH...

Jim Thomlinson


"JCIrish" wrote:

> Help. In inputBox the user enters a date (not usually the current date) for a
> month for which he wants to enter data. This is stored in the variable
> "userMonth" and entered into Range("F1"). I then use contents of F1 in a
> Find method to select a cell (labled mmm) into which to paste the entered
> data.
>
> My code checks inputBox entry for a valid date. If entry is valid (say,
> mmm,yy), here's the rub: I need to use only the mmm part in the Find method.
> Is it possible to capture only the mmm part of the entry or alternatively to
> retrieve only the mmm part from F1? Format (Date,"mmm") doesn't work here
> because the date may not be the current date. I know that I could have the
> user enter only the mmm in the inputBox but then I can't check that the entry
> is a valid date (at least I don't think I can).

 
Reply With Quote
 
=?Utf-8?B?SkNJcmlzaA==?=
Guest
Posts: n/a
 
      20th Oct 2006
Jim,
thanks for the response. I couldn't get that to work. I still end up with an
input in the form of mmm,yy in Cell F1 when I'm looking for just mmm

"Jim Thomlinson" wrote:

> Give this a whirl...
>
> MsgBox Format(CDate(InputBox("Enter a Date:")), "mmm")
> --
> HTH...
>
> Jim Thomlinson
>
>
> "JCIrish" wrote:
>
> > Help. In inputBox the user enters a date (not usually the current date) for a
> > month for which he wants to enter data. This is stored in the variable
> > "userMonth" and entered into Range("F1"). I then use contents of F1 in a
> > Find method to select a cell (labled mmm) into which to paste the entered
> > data.
> >
> > My code checks inputBox entry for a valid date. If entry is valid (say,
> > mmm,yy), here's the rub: I need to use only the mmm part in the Find method.
> > Is it possible to capture only the mmm part of the entry or alternatively to
> > retrieve only the mmm part from F1? Format (Date,"mmm") doesn't work here
> > because the date may not be the current date. I know that I could have the
> > user enter only the mmm in the inputBox but then I can't check that the entry
> > is a valid date (at least I don't think I can).

 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      20th Oct 2006
dim dt as Date, s as String

On Error Resume Next
dt = CDate(InputBox("Enter a Date:"))
if err.Number <> 0 then
msgbox "Bad Date"
exit sub
Exit sub
On Error goto 0


s = format(dt,"mmm")
Range("F1").value = "'" & s


or
Dim s as String
s = InputBox("Enter a 3 letter month name abbreviation")
if len(s) <> 3 then
Msgbox "Bad entry"
exit sub
end if
if not isdate(DateValue( s & " 1, 2006")) then
Msgbox "Bad entry"
exit sub
end if
Range("F1").Value = "'" & s


--
Regards,
Tom Ogilvy




"JCIrish" wrote:

> Jim,
> thanks for the response. I couldn't get that to work. I still end up with an
> input in the form of mmm,yy in Cell F1 when I'm looking for just mmm
>
> "Jim Thomlinson" wrote:
>
> > Give this a whirl...
> >
> > MsgBox Format(CDate(InputBox("Enter a Date:")), "mmm")
> > --
> > HTH...
> >
> > Jim Thomlinson
> >
> >
> > "JCIrish" wrote:
> >
> > > Help. In inputBox the user enters a date (not usually the current date) for a
> > > month for which he wants to enter data. This is stored in the variable
> > > "userMonth" and entered into Range("F1"). I then use contents of F1 in a
> > > Find method to select a cell (labled mmm) into which to paste the entered
> > > data.
> > >
> > > My code checks inputBox entry for a valid date. If entry is valid (say,
> > > mmm,yy), here's the rub: I need to use only the mmm part in the Find method.
> > > Is it possible to capture only the mmm part of the entry or alternatively to
> > > retrieve only the mmm part from F1? Format (Date,"mmm") doesn't work here
> > > because the date may not be the current date. I know that I could have the
> > > user enter only the mmm in the inputBox but then I can't check that the entry
> > > is a valid date (at least I don't think I can).

 
Reply With Quote
 
=?Utf-8?B?SkNJcmlzaA==?=
Guest
Posts: n/a
 
      21st Oct 2006
Tom,
Works like a charm, and your help taught me some code that I had no clue how
to use. Many thanks,

JCIrish

"Tom Ogilvy" wrote:

> dim dt as Date, s as String
>
> On Error Resume Next
> dt = CDate(InputBox("Enter a Date:"))
> if err.Number <> 0 then
> msgbox "Bad Date"
> exit sub
> Exit sub
> On Error goto 0
>
>
> s = format(dt,"mmm")
> Range("F1").value = "'" & s
>
>
> or
> Dim s as String
> s = InputBox("Enter a 3 letter month name abbreviation")
> if len(s) <> 3 then
> Msgbox "Bad entry"
> exit sub
> end if
> if not isdate(DateValue( s & " 1, 2006")) then
> Msgbox "Bad entry"
> exit sub
> end if
> Range("F1").Value = "'" & s
>
>
> --
> Regards,
> Tom Ogilvy
>
>
>
>
> "JCIrish" wrote:
>
> > Jim,
> > thanks for the response. I couldn't get that to work. I still end up with an
> > input in the form of mmm,yy in Cell F1 when I'm looking for just mmm
> >
> > "Jim Thomlinson" wrote:
> >
> > > Give this a whirl...
> > >
> > > MsgBox Format(CDate(InputBox("Enter a Date:")), "mmm")
> > > --
> > > HTH...
> > >
> > > Jim Thomlinson
> > >
> > >
> > > "JCIrish" wrote:
> > >
> > > > Help. In inputBox the user enters a date (not usually the current date) for a
> > > > month for which he wants to enter data. This is stored in the variable
> > > > "userMonth" and entered into Range("F1"). I then use contents of F1 in a
> > > > Find method to select a cell (labled mmm) into which to paste the entered
> > > > data.
> > > >
> > > > My code checks inputBox entry for a valid date. If entry is valid (say,
> > > > mmm,yy), here's the rub: I need to use only the mmm part in the Find method.
> > > > Is it possible to capture only the mmm part of the entry or alternatively to
> > > > retrieve only the mmm part from F1? Format (Date,"mmm") doesn't work here
> > > > because the date may not be the current date. I know that I could have the
> > > > user enter only the mmm in the inputBox but then I can't check that the entry
> > > > is a valid date (at least I don't think I can).

 
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
Picking part of a cell based on cell contents a.t.brooks@talk21.com Microsoft Excel Programming 7 25th Jul 2008 12:19 PM
Lookup part of a cell's contents and return value of entire cell Terri Microsoft Excel Misc 2 21st Feb 2008 03:53 AM
macro to move part of cell contents to another cell =?Utf-8?B?aWNldG9hZCAgaGlzc2VsZg==?= Microsoft Excel Misc 4 27th Nov 2006 07:19 PM
Display contents of cell in another cell as part of text string? mschmidt@carolina.rr.com Microsoft Excel New Users 3 8th Jul 2006 07:44 PM
Formula to capture cell location as opposed to cell contents Dan Microsoft Excel Worksheet Functions 0 10th Oct 2003 04:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:59 PM.