View Single Post
  #4   Report Post  
JMB
 
Posts: n/a
Default

Sorry. I had assumed you had set up a userform. Also, I misread - you have
the quantity, make, model and wish to add cost and shipping to new columns.

Assuming you want to add Cost to column 5 and shipping to column 6, the
itemnumber is in column A, this uses inputboxes to get the info from the user
and should put it in columns 5 and 6 of the proper row.

You'll need to insert a VBA code module into your workbook. Hit Alt-F11,
Find your workbook in the Project Explorer window and select it. Click
Insert/Modules. Copy and paste this macro into the Code Window that appeared
when you inserted the module.

You will need to verify this line of the macro is correct:

With Sheet1

To do this, make sure your control toolbar is visible (View/Toolbars/Control
Toolbox). Make sure the worksheet containing you data is the active sheet
and click on the properties button of the control toolbar (s/b second from
left). This will show the properties of the worksheet. The first one (Name)
is the code name for your worksheet and may or may not be the same as the
name on the tab of your worksheet (many folks use the code name instead of
the tab name - because it is less likely to be changed and cause the macro to
not find the worksheet). If the code name is not Sheet1 then change Sheet1
in the code to match whatever yours is.

Also if you need Cost and Shipping in columns other than 5 and 6, change the
constants CostCol and ShippingCol to whatever you need.

If you have not created the button, use the forms toolbar, click on the
button then "draw" the button on your worksheet. Excel should prompt you to
assign a macro to it. If not you should be able to right click on it and
select "assign macro".



Sub InputData()
Const CostCol As Integer = 5
Const ShippingCol As Integer = 6
Dim ItemNumber As Long
Dim Cost As Currency
Dim Shipping As Currency
Dim Row1 As Long

On Error GoTo ExitProgram

ItemNumber = InputBox("Enter Item Number:")
Cost = InputBox("Enter Item Cost:")
Shipping = InputBox("Enter Shipping Amount:")
Row1 = Application.Match(ItemNumber, Sheet1.Range("A:A"), 0)

With Sheet1
.Cells(Row1, 4).Value = Cost
.Cells(Row1, 5).Value = Shipping
End With

Exit Sub
ExitProgram:
MsgBox "An error occurred. Please check item number and try again."

End Sub




"Soundman" wrote:


Thanks for the help, but I'm not understanding how to implement this
code.


--
Soundman
------------------------------------------------------------------------
Soundman's Profile: http://www.excelforum.com/member.php...o&userid=24428
View this thread: http://www.excelforum.com/showthread...hreadid=380316