![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: May 2002
Location: California, USA
Posts: 1
|
Say, I have had a data base spreadsheet (Sheet A) with two columns data. Column A is listed with, say, item numbers; and column B is corresponding, say, UPC codes.
How can I do that whenever I type an item number and the corresponding UPC code will pop up automatically on another cell in, say, sheet B? |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Apr 2002
Location: Greenwood, SC
Posts: 677
|
Say you try this...
In the code for the worksheet you will be entering data (SheetB), place the following code: Private Sub Worksheet_Change(ByVal Target As Range) Dim i As Long With Sheets("SheetA") If Target.Column = 1 Then For i = 1 To 65000 If .Cells(i, 1).Value = "" Then Exit For If .Cells(i, 1).Value = Cells(Target.Row, 1).Value Then Cells(Target.Row, 2).Value = .Cells(i, 2).Value Exit For End If Next End If End With End Sub It will put the corresponding value from column B on sheetA into columnB on sheetB based on the values in row a on both sheets. K [ This Message was edited by: kkknie on 2002-05-17 11:46 ] [ This Message was edited by: kkknie on 2002-05-17 11:46 ] |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Feb 2002
Posts: 7,743
|
You could try using VLOOKUP
name your data In sheet B where you want the UPC code displayed enter =vlookup(a1,range,2) where a1 is where you enter the item no. sort you range |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|