Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default capture only part of inputBox or of cell contents

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).
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default capture only part of inputBox or of cell contents

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).

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default capture only part of inputBox or of cell contents

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).

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default capture only part of inputBox or of cell contents

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).

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default capture only part of inputBox or of cell contents

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
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
Looking Up Part Cell Contents Steve Excel Discussion (Misc queries) 2 April 22nd 09 05:20 PM
#N/A if cell contents not part of an array MichaelR Excel Discussion (Misc queries) 5 June 28th 08 03:09 AM
InputBox to capture user selected sheet names? quartz[_2_] Excel Programming 7 December 3rd 05 10:51 AM
Can I use cell contents as part of a formula? Brian Rhodes Excel Worksheet Functions 3 June 3rd 05 05:00 PM
Capture changing cell contents from DDE links OttoMagic Excel Programming 0 August 6th 04 04:19 AM


All times are GMT +1. The time now is 07:43 PM.

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"