close

Hi:

I have a column titled quot;Descriptionquot;

In one row of this column I have a entry for quot;Order No:quot;

Right now when a person tabs to this field with Order No. they have to
click to enter the order number. Is there a way to create a macro to
prompt the person for the order number and then when they press enter
or whatever that number is enter into the appropriate area? Or, is
there a way to split a cell?

Description

Order No: I have to click here to enter a number--
dah
------------------------------------------------------------------------
dah's Profile: www.excelforum.com/member.php...foamp;userid=6493
View this thread: www.excelforum.com/showthread...hreadid=504047You can use a macro that runs when you click on a cell (or tab into the
cell). The macro can prompt for a value and update any cell.

The code below will fire an input box when you click on cell B2. It will
then store the value in cell B2. Is something like this what you are looking
for?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = quot;$B$2quot; Then
Target.Value = InputBox(quot;Please enter an Order Numberquot;, quot;Order
Numberquot;)
End If
End Sub

quot;dahquot; wrote:

gt;
gt; Hi:
gt;
gt; I have a column titled quot;Descriptionquot;
gt;
gt; In one row of this column I have a entry for quot;Order No:quot;
gt;
gt; Right now when a person tabs to this field with Order No. they have to
gt; click to enter the order number. Is there a way to create a macro to
gt; prompt the person for the order number and then when they press enter
gt; or whatever that number is enter into the appropriate area? Or, is
gt; there a way to split a cell?
gt;
gt; Description
gt;
gt; Order No: I have to click here to enter a number
gt;
gt;
gt; --
gt; dah
gt; ------------------------------------------------------------------------
gt; dah's Profile: www.excelforum.com/member.php...foamp;userid=6493
gt; View this thread: www.excelforum.com/showthread...hreadid=504047
gt;
gt;


This appears to be what would work but I get an error message (compile)
that Sub Cellchange() is wrong.Sub CellChange()
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = quot;$B$25quot; Then
Target.Value = InputBox(quot;Please enter an Order Numberquot;, quot;Order
Numberquot;)
End If

End Sub--
dah
------------------------------------------------------------------------
dah's Profile: www.excelforum.com/member.php...foamp;userid=6493
View this thread: www.excelforum.com/showthread...hreadid=504047Drop the Sub CellChange()

Drop the last double quote. Good practice also to stick in an error trap to
re-enable events if an error occurs.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = quot;$B$25quot; Then
On Error GoTo CleanUp
Application.EnableEvents = False
Target.Value = InputBox(quot;Please enter an Order Numberquot;, quot;Order Number quot;)
End If
CleanUp:
Application.EnableEvents = True
End SubGord Dibben MS Excel MVP

On Mon, 23 Jan 2006 13:40:21 -0600, dah
gt; wrote:

gt;
gt;This appears to be what would work but I get an error message (compile)
gt;that Sub Cellchange() is wrong.
gt;
gt;
gt;Sub CellChange()
gt;Private Sub Worksheet_SelectionChange(ByVal Target As Range)
gt;If Target.Address = quot;$B$25quot; Then
gt;Target.Value = InputBox(quot;Please enter an Order Numberquot;, quot;Order
gt;Numberquot;)
gt;End If
gt;
gt;End Sub

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()