简体   繁体   中英

How to find information for each cell of column from other sheet?

I have two sheets and in one of them we have database for all the computers of the company and its related information "eg. Mac Address and Manufacturer" and in other sheet I have random computer numbers. How can I find mac address and Manufacturer name for all the cells of sheet 2 in one go? I cansearch for each computer no. individually but it can take alot of time.

It sounds like you need to use the vlookup() function in sheet 2. This will allow you to, row by row, look for the presence of computer x in sheet 1 and return the MAC address...assuming. (1) these random computer numbers listed in sheet 2 are numbers in a column of sheet 1. (2) Sheet 1 has the MAC address in a separate column to the computer number, and to the right of it!

If you look up the vlookup() function in the Excel help it will also spell that out nice and clearly.

You can do this with two loops like the following:

dim counter x as long
dim finish as boolean
dim counter inner as long
x = 1
    do until isempty(worksheets("a").cells(x,1).value)
       finish = false
       inner = 1
       do until isempty(worksheets("b").cells(inner,1).value) or finish = true
          if worksheets("a").cells(x,1).value = worksheets("b").cells(inner,1).value then
            finish = true
          end if
       loop
       if finish = true then
            //copy data
       end if
    loop

You go through the table with the random computers (we call this outer loop) in this loop you go every time thorugh the other table (inner loop) where you search with your key and if you find the key set a boolean on true.

Jump out the loop when you do not have more rows or you find your target.

After it check if you find it and set the data you got in your inner loop for your current row in your outer loop then you have to reset the counter for your inner loop and the boolean and go forward with the next row in your outer loop.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM