Lookup Data in external workbook

Hello:

I have a worksheet called "PlantAnalysis". Column A has the "Item ID" and I 
would like to put the description in column B; starting at cell B3. I am 
trying to lookup the Item Description from an external workbook called "Item 
master" on worksheet labelled "List". Column A has the "Item ID" and Column C 
has the "Description".Is VLookup the recommended way to do this? Below is 
what I have but can't get it to work.

Sub getdesc()

'Inserting vlookup statement to populate material description
       
    Dim MyRange As range
    Dim LastRow As Long
    Dim rng As range
        With Sheets("PlantAnalysis")
        'find last row in column A
        LastRow = sh.range("A" & Rows.Count).End(xlUp).Row
        'set range to loop thru
        Set MyRange = .range("A3:A" & LastRow)
        For Each rng In MyRange
        'test if rng is empty, if so skip it
        If Not IsEmpty(.Cells(rng.Row, "A")) Then
        .cells(rng.row,"B3:B")= Application.vlookup(rng,'C:\[ItemMaster.xls 
List'!"$A:$C",3,FALSE)
        End If
    Next range
    End With
End Sub
0
Utf
2/5/2010 5:23:01 PM
excel.programming 6508 articles. 2 followers. Follow

3 Replies
613 Views

Similar Articles

[PageSpeed] 59

First, the table file in your =vlookup() formula has to be open if the code is
going to work.

And then you'd use something like:

   .cells(rng.row,"B3:B")= Application.vlookup(rng, _
                              workbooks("ItemMaster.xls").worksheets("list") _
                                .range("A:C"), 3, false)

if the itemaster.xls workbook won't be open, then I'd just plop the formula into
the cell (and convert it to values????).

Ray wrote:
> 
> Hello:
> 
> I have a worksheet called "PlantAnalysis". Column A has the "Item ID" and I
> would like to put the description in column B; starting at cell B3. I am
> trying to lookup the Item Description from an external workbook called "Item
> master" on worksheet labelled "List". Column A has the "Item ID" and Column C
> has the "Description".Is VLookup the recommended way to do this? Below is
> what I have but can't get it to work.
> 
> Sub getdesc()
> 
> 'Inserting vlookup statement to populate material description
> 
>     Dim MyRange As range
>     Dim LastRow As Long
>     Dim rng As range
>         With Sheets("PlantAnalysis")
>         'find last row in column A
>         LastRow = sh.range("A" & Rows.Count).End(xlUp).Row
>         'set range to loop thru
>         Set MyRange = .range("A3:A" & LastRow)
>         For Each rng In MyRange
>         'test if rng is empty, if so skip it
>         If Not IsEmpty(.Cells(rng.Row, "A")) Then
>         .cells(rng.row,"B3:B")= Application.vlookup(rng,'C:\[ItemMaster.xls
> List'!"$A:$C",3,FALSE)
>         End If
>     Next range
>     End With
> End Sub

-- 

Dave Peterson
0
Dave
2/5/2010 5:50:27 PM
And 

..cells(rng.row,"B3:B")
would be more like:

..cells(rng.row,"B")

(I didn't look at the rest of your code.)

Dave Peterson wrote:
> 
> First, the table file in your =vlookup() formula has to be open if the code is
> going to work.
> 
> And then you'd use something like:
> 
>    .cells(rng.row,"B3:B")= Application.vlookup(rng, _
>                               workbooks("ItemMaster.xls").worksheets("list") _
>                                 .range("A:C"), 3, false)
> 
> if the itemaster.xls workbook won't be open, then I'd just plop the formula into
> the cell (and convert it to values????).
> 
> Ray wrote:
> >
> > Hello:
> >
> > I have a worksheet called "PlantAnalysis". Column A has the "Item ID" and I
> > would like to put the description in column B; starting at cell B3. I am
> > trying to lookup the Item Description from an external workbook called "Item
> > master" on worksheet labelled "List". Column A has the "Item ID" and Column C
> > has the "Description".Is VLookup the recommended way to do this? Below is
> > what I have but can't get it to work.
> >
> > Sub getdesc()
> >
> > 'Inserting vlookup statement to populate material description
> >
> >     Dim MyRange As range
> >     Dim LastRow As Long
> >     Dim rng As range
> >         With Sheets("PlantAnalysis")
> >         'find last row in column A
> >         LastRow = sh.range("A" & Rows.Count).End(xlUp).Row
> >         'set range to loop thru
> >         Set MyRange = .range("A3:A" & LastRow)
> >         For Each rng In MyRange
> >         'test if rng is empty, if so skip it
> >         If Not IsEmpty(.Cells(rng.Row, "A")) Then
> >         .cells(rng.row,"B3:B")= Application.vlookup(rng,'C:\[ItemMaster.xls
> > List'!"$A:$C",3,FALSE)
> >         End If
> >     Next range
> >     End With
> > End Sub
> 
> --
> 
> Dave Peterson

-- 

Dave Peterson
0
Dave
2/5/2010 6:41:05 PM
Thanks Dave,
I was able to sovlve wthout having to open the workbook

"Dave Peterson" wrote:

> And 
> 
> ..cells(rng.row,"B3:B")
> would be more like:
> 
> ..cells(rng.row,"B")
> 
> (I didn't look at the rest of your code.)
> 
> Dave Peterson wrote:
> > 
> > First, the table file in your =vlookup() formula has to be open if the code is
> > going to work.
> > 
> > And then you'd use something like:
> > 
> >    .cells(rng.row,"B3:B")= Application.vlookup(rng, _
> >                               workbooks("ItemMaster.xls").worksheets("list") _
> >                                 .range("A:C"), 3, false)
> > 
> > if the itemaster.xls workbook won't be open, then I'd just plop the formula into
> > the cell (and convert it to values????).
> > 
> > Ray wrote:
> > >
> > > Hello:
> > >
> > > I have a worksheet called "PlantAnalysis". Column A has the "Item ID" and I
> > > would like to put the description in column B; starting at cell B3. I am
> > > trying to lookup the Item Description from an external workbook called "Item
> > > master" on worksheet labelled "List". Column A has the "Item ID" and Column C
> > > has the "Description".Is VLookup the recommended way to do this? Below is
> > > what I have but can't get it to work.
> > >
> > > Sub getdesc()
> > >
> > > 'Inserting vlookup statement to populate material description
> > >
> > >     Dim MyRange As range
> > >     Dim LastRow As Long
> > >     Dim rng As range
> > >         With Sheets("PlantAnalysis")
> > >         'find last row in column A
> > >         LastRow = sh.range("A" & Rows.Count).End(xlUp).Row
> > >         'set range to loop thru
> > >         Set MyRange = .range("A3:A" & LastRow)
> > >         For Each rng In MyRange
> > >         'test if rng is empty, if so skip it
> > >         If Not IsEmpty(.Cells(rng.Row, "A")) Then
> > >         .cells(rng.row,"B3:B")= Application.vlookup(rng,'C:\[ItemMaster.xls
> > > List'!"$A:$C",3,FALSE)
> > >         End If
> > >     Next range
> > >     End With
> > > End Sub
> > 
> > --
> > 
> > Dave Peterson
> 
> -- 
> 
> Dave Peterson
> .
> 
0
Utf
2/5/2010 10:40:15 PM
Reply:

Similar Artilces:

Pivot Table Source Data
I have an existing Pivot Table that usually updates daily, albeit this relies someone in the office refreshing the data. Anyway we seem to have missed one days data and thought we would be clever and just include the days missing data back into the source data. In effect we are putting the 8th September data between the 7th and the 9th. However no matter what we do the data from the 8th ends up as the last column in the pivot table. Are we missing something really simple here or has my brain turned to mush? thanks for the help in advance. Bryan P.S I also tried creating a dynamic range but ...

EXCEL tabular data extract
Hi all! Hi have a excel file with the next kind of data: T�TULO MINORISTA NOMBRE XXXXXXXXX CENT./SUC. RRRRRRRR DIRECCI�N TTTTTTTT LOCALIDAD VVVVVVVVVVV PROVINCIA SSSSSSSSSSS C.P. 11111 TEL�FONO 4323543543654364 FAX 435435454543543543 T�TULO MINORISTA NOMBRE XXXXXXXXX CENT./SUC. RRRRRRRR DIRECCI�N TTTTTTTT LOCALIDAD VVVVVVVVVVV PROVINCIA SSSSSSSSSSS C.P. 11111 TEL�FONO 4323543543654364 FAX 435435454543543543 I want to extract all the faxes from that table, bu the problem is that all...

how do i create an office data connection file
i want to call a parameterized data connection. i want to eventually put this in office sharepoint server 2007's data connection library. every time i open the connection file i have successfully created that connects to the db, it want me to pick a table. i can cancel out of that and change it to sql and say to use a procedure, but i can't save this file, and the "Edit Query..." and "Parameters..." buttons are disabled so i can't set parameters. why is it so hard to work with this thing? thanks ...

Linked cells in Multiple Workbooks
I am tracking dates and have linked cells from another workbook so as t not have to duplicate the data entry of dates. The dates are linked t projects that are listed in rows and there is information in m workbook that is additional information within the row. So if someon changes the order of the other workbook, the information that is in m workbook does not get sorted with the order. Is there a way to link m cells to the linked cells? ie. Project ID Start Date Milestone EndDate Person Assigned 1234 (linked) 11/15/04 11/20/04(lin...

Stripping Blank Characters form Imported Data
I am trying to verify 2 worksheets full of data. One has been imported from Visual Basic and the other from Business Object. The Business object sheet, brings over the entire field not just the charaters needed. Example: For the city field there are 50 characters available. If you use Nashville, the Business Object brings over 50 characters where the Visual Basic brings over 9. When trying to find descrepancies, this brings back a false positive if the city is the same. Is there a way to manipulate that data when it is sent to Excel? The easiest way to deal with this would be to find...

Data Tables
In Excel 2000, must data tables (Data\Tables...) always be located on the same worksheet tab as the source data? I want to put summary tables into a separate worksheet (tab), but Excel won't let me do that. Steve Looks that way, at least in Excel97 (my ver) But we could always mirror the data tables (or parts thereof) elsewhere (eg: another sheet) via simple link formulas -- Rgds Max xl 97 --- Singapore, GMT+8 xdemechanik http://savefile.com/projects/236895 -- "Steve D" <sdrenker_(you_know_what_here)_media.sj.nec.com> wrote in message news:ufhMsZfyFHA.3804@TK2MSFTNGP10....

Data Validation problem #5
hi I think that is a different solution entirely - in that example yo gave me it is a simple case of choosing one list and that then sets th range for list 2, however the second set of lists are all individual my requirement is that the validation picks the required items out o just ONE list, whereas in the example you needed to maintain individua lists each of which was dependant on the first selection -- moosife ----------------------------------------------------------------------- moosifer's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1590 View this threa...

How do I limit labels in chart legend to only a portion of data?
I am hoping to get a chart that includes four lines of data, but with only two of the line labels for the data showing up in the chart legend. The two lines that I want excluded are just straight bars that will include a text box within the chart as their label, but I have run into problems with simply slapping a line on the chart as it does not move around when we scale up or down the two axes. Is there a way to get the legend to only show the label identifiers with only the two sets of data that I want shown? Thank you Hi, The legend displays an entry for each series in the chart....

delete data #2
Hello, we have CRM v3 installed in a test evironment. we have added test data for customers, products. we have created oppurtunities to invoices. we would like to delete all of this data. is there a way to do it without uninsalling and reinstalling the software? cheers, Michael. Try to delete via the UI from Advanced Find. For some of the object (Order, Invoices, Quote, etc.), depending on status some of these records cannot be deleted. Frank Lee, Microsoft CRM MVP http://microsoft-crm.spaces.live.com http://www.workopia.com/Links.htmTry "Michael P. Lindekugel" wrote:...

Merge data
..Net 2003 C# I get xml from a sql database pull. I put the data into a XMLDomDocument and then the user changes it. I now need to update the database correctly. I need to be able to get the data back correctly including add, change and delete to the original data. When I pull the data from the db, I store a copy in a Dataset. So I end up with a Dataset (original data) and an XML DOM Document with the changed data. I would appreciate knowing how to do this correctly. I understand that the DataSet.Merge does not work for some of this. Is there an example? thank you If you keep the dat...

Formatting number in Data Table
I am using Excel 2007. I have a spreadsheet that the figures can be negative or positve. I have formatted the cells with this custom format $#,##0;[Red]$-#,##0. On the spreadsheet the format works fine. I created a chart from the data. I have a data table at the bottom of the chart. The problem is that the format from the spreadsheet is not reflected in the data table. When I click on Format Data Table, there is no option for number formatting. There is a number formatting option available when i click Format Axis, but this doesn't change it, because the actual axis is Text. Is th...

Copying Data From SQL Into Excel
When I copy a range of data from SQL and paste it into Excel, the data doesn't appear to be available for formulas - in this case a VLOOKUP formula. However, once I click in the formula bar (as if to edit the data) then hit "return" the data is "magically" available for the VLOOKUP formula. It seems to me to be a format problem, but changing the format of the data doesn't help. Could this be related to similar issues when copying data from Access into Excel? Are there any workarounds? It sounds similar to the Access problem. Instead of pasting, you can ...

master list for auto complete data?
Is it possible to have a master list, in my case it's of names, in a workbook that excel will use for auto complete data for that workbook? Thanks Hi Tangy Go to "Tools>Auto Correct Options", select the "Auto Correct" tab and enter the abbreviated items and full names for those items you want Excel to replace. Ensure the relevant boxes are ticked. -- XL2002 Regards William willwest22@yahoo.com "Tangy" <t a n g y@rogers.com> wrote in message news:_OqdnbKPa7IShELcRVn-jQ@rogers.com... | Is it possible to have a master list, in my case it'...

Data from non-adjacent cells as input for Linest
Hi, I would like to use data as input for Linest that is in the following cells: known y: A1 to A3, A10 to A12 known x: B1 to B3, B10 to B12 I have the feeling that this is almost answered in the following posts, but I do not understand it: http://groups.google.com/group/microsoft.public.excel/browse_thread/thread/fe4463f591797f44/4061a15313417929?lnk=gst&q=linest+#4061a15313417929 Regards, David ...

copy and match data from one worksheet into another via script?
Hi all I have two worksheets 2 columns each The first sheet has ID and Name Column for example: Code ------------------- ID[/B] NAM 193948 Michael 684588 John 535279 Luke 098734 Matthe ------------------- my 2nd sheet Code ------------------- ID [B]NAM Michael John Luke Matthe ------------------- How do i use the first sheet to match up the names on the 2nd sheet and ultimately copy the ID numbers onto the 2nd sheet? This is just a simplified example. There are thousands of entries. Thank you if you have ...

LNK2001: unresolved external
I've hit a brick wall with this one. I have a project that compiles and runs fine in debug mode. I switch to release build the linker fails claiming it can't find one of my class' functions. Which is plainly there. It is always the destructor it can't find i.e if I bin my class and create an entirely new one with just a constructor and destructor that too fails to link, claiming it cant find the constructor. I've never seen this behavour before, what can I have done wrong ??? If I delete the destructors implementation from the relevent CPP file and put it directly ...

How do I look at two worksheets in one Excel workbook at same time
I know how to arrange windows to look at multiple workbooks. But I want to have two worksheets displayed at the same time from the same workbook. Is there a way to do that? Window - New Window this will create a second view of active workbook. Then you can do Window - Arrange, active workbook only. -- Best Regards, Luke M "PeoriaJean" <PeoriaJean@discussions.microsoft.com> wrote in message news:503A1BB9-2130-4346-A0AF-A461388397B2@microsoft.com... >I know how to arrange windows to look at multiple workbooks. But I want to > have two worksheets di...

how to deal with duplicate data rows
I need to interface with a program that generates a .csv file with row of data. It generates 2 or more rows for each instance uniquely identified by the docket/page combination Example: last first bank trustee docket page smith john ny bank (blank field) 12235 8907 (blank field) (blank field) cal western 12235 8907 smith janet ny bank (blank field) 12235 8907 I need to consolidate all three lines into one row by concating field that contain different data (first name column) and columns with blan spaces to look like the ...

Merge & Sort Dynamic Lists w/ Data Validation
First off, let me say thanks to the Excel Usenet community that has helped me over and over through these newsgroups. You are phenomenal. Question 1: I need to create a BOTH box that will dynamically pull names from both the "Chicago Office" & "Seattle Office" columns in my sheet. It is extremely preferable to do this without VB Script if possible to avoid the security warnings on opening the sheet. (Our IT department will not budge on this..) Detail: I have two lists of employees. Column A lists the Chicago Office employees. Column B lists the Seattle Office employee...

Importing data from an excel file
I have an excel file with contact data for customers. Now I want to import it into CRM 3.0. I use the guide but I am stuck at the manual import i.e. populate CDF at step 5 in the data migration framework application. Do I have to go to the SQL server and select the database and import into the contacts table? I am really sorry for the newbie question.. /Jonas Hi Jonas, You will indeed need to populate the CDF tables. You can do this via several ways of which using SSIS is my personal favorite. Hope this helps, -- Ronald Lemmen - MSCRM MVP Avanade Netherlands http://ronaldlemmen.blog...

Workbook there but not visible! Help!
I was working on some VBA code for an excel application I am writing. I switched between the VBE and the spreadsheet and all of a sudden my workbook is no longer visible! In the VBE project explorer window it shows my project and my code but in the excel window...no workbook! Nothing! Ran a test procedure calling IsAddin to see if somehow I accidentally clicked a button/box telling Excel to make this file an addin but it returned false. I did close the file and re-open it. Any ideas? Maybe it's just off the visible screen: Window|Arrange|tiled (and resize manually) or maybe y...

Passing data to DLL problem
Hi, my application uses a callback function in a dll. This function must notify the main application when it is called, through a SendMessage api call. So i've created a global variable in the dll, named parent: HWND parent; LRESULT CALLBACK MyFunction(...........) { ......................... SendMessage(parent, ....................); } in the main application i set the dll variable: HWND * wnd; wnd = (HWND *) GetProcAddress(hinstDLL, "parent"); *wnd = hWnd; this works fine if i use the parent variable it in a normal dll function, but in the callback MyFunction parent resu...

Adding a total row to a chart data table
I have the following data in a chart Week 1 2 3 4 5 6 7 8 Data1 1 5 7 6 1 6 7 6 Data2 3 4 5 7 9 4 6 6 Is it possible to have the data table show a totals row? I.E: Totals 4 9 12 13 10 10 13 12 Thanks in advance, John You can't include the total in the data table. As a workaround, you could embed the chart on a worksheet, and display the data below it. Tushar Mehta has instructions on his web site: http://tushar-mehta.com/excel/newsgroups/data_table/index.htm John Ortt wrote: > I have the following data in a chart > > Week 1 2 3 4 5 6 7 8 > Data1 1 5 7 6 1 6 7 6...

how do I set up spread sheet for demographical data to get graph.
I need to set up a spread sheet to be able to get age, sex,service usage numbers, site utilisation, presenting issue e.g., drug and alcohol, region, percentage of use base on population e.g, 80 staff DoHi, Do you want to show these results graphically, or in the form of some sort of output table? Dave url:http://www.ureader.com/msg/10355820.aspx How are you intending to get the data or enter the data into this sheet? How many worksheets or tables will you need? What is the final display options: Examples, Reports, Charts, Pivot = table? And lastly who are the end users, and how do they...

external members of distribution groups do not see all addressees
Hello, We are running Exchange 2003 with some clients using Outlook 2003 and some Outlook XP. When they send email to a distribution group which has both internal and external addresses. Those internal users see in the To: or CC: all of the addressees, but those with external addresses only see some of the addressees. How can I get it to show all recipients for everyone? Thanks ...