PC Review


Reply
Thread Tools Rate Thread

cell formatting & Input box

 
 
=?Utf-8?B?U29sQXI=?=
Guest
Posts: n/a
 
      13th Mar 2007
Hi,
the format of cell p_1 is "dd-mm-yy hh:mm"

this procedure running inputbox:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim row As Integer
Range("p_1").Select
With ActiveCell.NumberFormat = "dd-MM-yy hh:mm"
End With
If Target.row = 3 And Target.Column = 2 And Range("p_1").Value = "" Or
Range("p_1").Value = 0 Then _
: Range("p_1").Value = InputBox("Wpisz datę" & vbNewLine & vbNewLine &
"Początkową" & vbNewLine & vbNewLine & "Delegacji PL:")
Range("K_1").Select
With ActiveCell.NumberFormat = "dd-MM-yy h:mm"
End With
If Target.row = 3 And Target.Column = 3 And Range("K_1").Value = "" Or
Range("K_1").Value = 0 Then _
: Range("K_1").Value = InputBox("Wpisz datę" & vbNewLine & vbNewLine &
"Końcową" & vbNewLine & vbNewLine & "Delegacji PL:")
End Sub

!!! however, input box changing format of cell p_1 to "mm-dd-yy hh:mm" !!!

what should I declare, to write correctly date in cell p_1 ???

thx in advance
Artur
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      13th Mar 2007
You'll have to change the prompt. The characters got mangled in the post.

Maybe something like:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Me.Range("B3:C3")) Is Nothing Then
Exit Sub
End If
Me.Range("p_1").NumberFormat = "dd-MM-yy hh:mm"
Me.Range("k_1").NumberFormat = "dd-MM-yy hh:mm"

If Not (Intersect(Target, Me.Range("b3")) Is Nothing) Then
'in B3
With Me.Range("p_1")
If .Value = 0 _
Or .Value = "" Then
Application.EnableEvents = False
.Value = InputBox("yourPrompthere")
Application.EnableEvents = True
End If
End With
Else
'must be in C3
With Me.Range("k_1")
If .Value = 0 _
Or .Value = "" Then
Application.EnableEvents = False
.Value = InputBox("yourPrompthere")
Application.EnableEvents = True
End If
End With
End If
End Sub

SolAr wrote:
>
> Hi,
> the format of cell p_1 is "dd-mm-yy hh:mm"
>
> this procedure running inputbox:
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> Dim row As Integer
> Range("p_1").Select
> With ActiveCell.NumberFormat = "dd-MM-yy hh:mm"
> End With
> If Target.row = 3 And Target.Column = 2 And Range("p_1").Value = "" Or
> Range("p_1").Value = 0 Then _
> : Range("p_1").Value = InputBox("Wpisz datę" & vbNewLine & vbNewLine &
> "Początkową" & vbNewLine & vbNewLine & "Delegacji PL:")
> Range("K_1").Select
> With ActiveCell.NumberFormat = "dd-MM-yy h:mm"
> End With
> If Target.row = 3 And Target.Column = 3 And Range("K_1").Value = "" Or
> Range("K_1").Value = 0 Then _
> : Range("K_1").Value = InputBox("Wpisz datę" & vbNewLine & vbNewLine &
> "Końcową" & vbNewLine & vbNewLine & "Delegacji PL:")
> End Sub
>
> !!! however, input box changing format of cell p_1 to "mm-dd-yy hh:mm" !!!
>
> what should I declare, to write correctly date in cell p_1 ???
>
> thx in advance
> Artur


--

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
Conditional formatting - getting input from another cell EricD Microsoft Excel Worksheet Functions 6 1st Oct 2009 05:17 PM
Formatting the text in an input box and setting the format of the resident cell Doctorjones_md Microsoft Access Macros 1 31st Jan 2007 08:08 PM
Formatting the text in an input box and setting the format of the resident cell Doctorjones_md Microsoft Access 1 31st Jan 2007 08:08 PM
Formatting the text in an input box and setting the format of the resident cell Doctorjones_md Microsoft Access Forms 1 31st Jan 2007 08:08 PM
Formatting to show 0 as first number in a cell when input =?Utf-8?B?dHJpZmZpZGJvb2s=?= Microsoft Excel Worksheet Functions 5 25th Sep 2006 02:56 AM


Features
 

Advertising
 

Newsgroups
 


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