Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Copy the value in the Inputbox

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Copy the value in the Inputbox

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Copy the value in the Inputbox

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Copy the value in the Inputbox

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
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
Copy a range with application.inputbox excelent Excel Programming 3 April 2nd 07 05:30 AM
Inputbox help... ChrisMattock[_11_] Excel Programming 3 May 12th 06 02:21 PM
InputBox smandula Excel Programming 7 July 28th 05 08:33 AM
Inputbox and Application.InputBox Maria[_7_] Excel Programming 1 September 20th 04 11:36 AM
InputBox Hargrove Excel Programming 2 April 29th 04 07:43 PM


All times are GMT +1. The time now is 03:06 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"