PC Review


Reply
Thread Tools Rate Thread

Copy the value in the Inputbox

 
 
maywood
Guest
Posts: n/a
 
      27th Oct 2009
Hi,
I am using an InputBox to enter a date. This date should be copied into the
cell (4,7) in the format "mmm. yy". How to manage that.

Here is my code for the inputbox:

Private Sub CommandButton2_Click()
Dim d As Date
On Error GoTo err

Begin:
d = InputBox("Please enter a start date for the scenario!", _
"Start date")
If IsDate(d) And d >= "01.01.2008" Then
Else
MsgBox "No existing input data for this date!"

GoTo Begin
End If

Exit Sub

err:
MsgBox "Please only enter a valid date!"
GoTo Begin
End Sub
 
Reply With Quote
 
 
 
 
Patrick Molloy
Guest
Posts: n/a
 
      27th Oct 2009
don't confuse format with content. A cell can hold a date and be formatted so
that you see something else, such as MMM-YY or DDD

Option Explicit
Private Sub CommandButton2_Click()
Dim d As String
Do
d = InputBox("Please enter a start date for the scenario!", _
"Start date")
If IsDate(d) And d >= "01.01.2008" Then
Exit Do
Else
MsgBox "No existing input data for this date!"
Exit Sub
End If
Loop

Worksheets(">>>").Cells(4, 7).Value = Format$(d, "mmm.yy")

End Sub





"maywood" wrote:

> Hi,
> I am using an InputBox to enter a date. This date should be copied into the
> cell (4,7) in the format "mmm. yy". How to manage that.
>
> Here is my code for the inputbox:
>
> Private Sub CommandButton2_Click()
> Dim d As Date
> On Error GoTo err
>
> Begin:
> d = InputBox("Please enter a start date for the scenario!", _
> "Start date")
> If IsDate(d) And d >= "01.01.2008" Then
> Else
> MsgBox "No existing input data for this date!"
>
> GoTo Begin
> End If
>
> Exit Sub
>
> err:
> MsgBox "Please only enter a valid date!"
> GoTo Begin
> End Sub

 
Reply With Quote
 
Gary''s Student
Guest
Posts: n/a
 
      27th Oct 2009
Just format the cell first:

Sub TimeEntry()
Dim d As Date, s As String
s = Application.InputBox(prompt:="give me a date", Type:=2)
d = DateValue(s)
With Cells(4, 7)
.NumberFormat = "mmm. yy"
.Value = d
End With
End Sub
--
Gary''s Student - gsnu200908


"maywood" wrote:

> Hi,
> I am using an InputBox to enter a date. This date should be copied into the
> cell (4,7) in the format "mmm. yy". How to manage that.
>
> Here is my code for the inputbox:
>
> Private Sub CommandButton2_Click()
> Dim d As Date
> On Error GoTo err
>
> Begin:
> d = InputBox("Please enter a start date for the scenario!", _
> "Start date")
> If IsDate(d) And d >= "01.01.2008" Then
> Else
> MsgBox "No existing input data for this date!"
>
> GoTo Begin
> End If
>
> Exit Sub
>
> err:
> MsgBox "Please only enter a valid date!"
> GoTo Begin
> End Sub

 
Reply With Quote
 
maywood
Guest
Posts: n/a
 
      27th Oct 2009
Works! Thanks allot!

"Gary''s Student" wrote:

> Just format the cell first:
>
> Sub TimeEntry()
> Dim d As Date, s As String
> s = Application.InputBox(prompt:="give me a date", Type:=2)
> d = DateValue(s)
> With Cells(4, 7)
> .NumberFormat = "mmm. yy"
> .Value = d
> End With
> End Sub
> --
> Gary''s Student - gsnu200908
>
>
> "maywood" wrote:
>
> > Hi,
> > I am using an InputBox to enter a date. This date should be copied into the
> > cell (4,7) in the format "mmm. yy". How to manage that.
> >
> > Here is my code for the inputbox:
> >
> > Private Sub CommandButton2_Click()
> > Dim d As Date
> > On Error GoTo err
> >
> > Begin:
> > d = InputBox("Please enter a start date for the scenario!", _
> > "Start date")
> > If IsDate(d) And d >= "01.01.2008" Then
> > Else
> > MsgBox "No existing input data for this date!"
> >
> > GoTo Begin
> > End If
> >
> > Exit Sub
> >
> > err:
> > MsgBox "Please only enter a valid date!"
> > GoTo Begin
> > End Sub

 
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
Copy a range with application.inputbox =?Utf-8?B?ZXhjZWxlbnQ=?= Microsoft Excel Programming 3 2nd Apr 2007 05:30 AM
inputbox brownti via OfficeKB.com Microsoft Excel Misc 2 9th Feb 2007 02:37 PM
Inputbox and Application.InputBox Maria Microsoft Excel Programming 1 20th Sep 2004 11:36 AM
InputBox() or equivalent functionality (Copy text to clipboard) goonsquad Microsoft C# .NET 2 31st Oct 2003 09:02 PM
VB InputBox Mori Microsoft C# .NET 7 15th Jul 2003 01:46 PM


Features
 

Advertising
 

Newsgroups
 


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