Filling a cell for Data Entry

bassbone

New Member
Joined
Apr 25, 2002
Messages
1
I have a spreadsheet where I have approx. 50 product codes. When I select a product code, I want Excel to fill in the cost (from a list on a separate sheet) in the cell next to the product code. In the past I've used nested "IF" statements, but I have what appears to be more ifs than exel can handle.

Thanks for the help
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Try using VLOOKUP where
Column A has your product code
Column B your cost adjacent to the product code.

=vlookup(C1,range,2)

Where C1 is where you enter your product code
 
Upvote 0
Hi BassBone,

If you want to do this with vba:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As _ Excel.Range)
Dim Code As Integer

If Target.Cells.Count > 1 Then End
If Target.Row >= 4 Then
If Target.Column = 2 Then
code = Target
Application.EnableEvents = True
Sheets("Sheet2").Range("B5").Offset(code, 0) - Resize(1, :cool:.Copy _ Destination:=Target.Offset(0, 1)
Target.Offset(1, 0).Activate
End If
End If
Application.EnableEvents = True
End Sub

James
 
Upvote 0

Forum statistics

Threads
1,213,527
Messages
6,114,142
Members
448,551
Latest member
Sienna de Souza

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top