IF there is a customer # in cell D2 on the main worksheet I need it to pull the customer's name from the Customer Base Price Sheet (worksheet within the same workbook) the customer's name is located in column B next to the customer's # on the customer base price sheet worksheet.
I am needing it to automatically give my worksheet the customer's name whenever I enter in the customer's number.
Pulling information from other worksheets in a workbook
-
-
-
Re: Pulling information from other worksheets in a workbook
Hi Alayna and welcome,
I couldn't decide whether you just wanted the customers name returned in a cell next to the customer # or whether you actually wanted to change the sheets name.
So I did bothQuoteI am needing it to automatically give my worksheet the customer's name
To do a lookup in a cell use
In order to change the sheetname you will need to use some VBA code.
Add this to the code module of the sheet you want to change.Code
Display MorePrivate Sub Worksheet_Change(ByVal Target As Range) Dim rngCust As Range If Not Intersect(Target, Range("D2")) Is Nothing Then If Target.Text <> "" Then Set rngCust = Worksheets("Customer Base Price").Range("A:A").Find(Target.Text, LookIn:=xlValues) If Not rngCust Is Nothing Then Worksheets(Target.Parent.Name).Name = rngCust.Offset(0, 1) End If End If End If End Sub
If you are changing sheet names you will have to careful that the customer names do not contain any illegal characters.
-
Re: Pulling information from other worksheets in a workbook
I entered the formula: =VLOOKUP(D2, 'CUST BASE PRICE SHEET'!A2:B11,2) and it pulls generally what I need however its not pulling the names quite right... My list for the customer number/name is layed out like the following:
A2 B2 C2
10001 New Customer #1
41276 Bargains #3This list goes from cells A2;A40 B2;B40 and C2;C40
On some of the customer #s listed in column A (A3 for example) instead of pulling the name from B3 it is pulling a name from B10
How can I fix that?
-
Re: Pulling information from other worksheets in a workbook
The quickest way would be to change the layout of your table
A2 B2 C2
#1 10001 New Customer
#3 41276 BargainsIf you can not change the layout of the table then use this revised formula.
-
Re: Pulling information from other worksheets in a workbook
Thanks, Andy!
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!