none
VB.NET Find Value in column A and then copy row RRS feed

  • Question

  • Hi,

    I have an issue using VB and excel together..

    I have been trying to search for a specific value in column A of the spreadsheet and once found to copy the row and have all data in different strings...

    So for Example:

    A B C D

    001 City User E-mail

    002 City User E-mail

    003 City User E-mail

    So basically I search for example "002" and then will provide all the other data in different strings for each.

    I am new to this so any help is appreciated!



    • Edited by TheOrion666 Tuesday, February 24, 2015 1:42 AM
    Tuesday, February 24, 2015 1:41 AM

All replies

  •  found to copy the row and have all data in different strings...

     and then will provide all the other data in different strings for each.



    can provide detailed explain for this, failed to see this , or provide a sample for this ?
    Thursday, February 26, 2015 8:51 AM
  • If your data is a unique list of STRING values then you can use the Application.match function.

    Here is a simple example of a single execution. Depending on how you feed the lookup value you may want to use this in a loop. Note that if you do you must reset the rowindex to 0 on each iteration.

    Dim rowindex as long
    dim lookupvalue as string
    dim stringx as string
    
    rowindex = Application.worksheetfunction.match(lookupvalue, range("A:A"), 0)
    if rowindex > 0 then
         stringx = Range("B" & rowindex)
    end if
    
    There are other ways to do this with arrays as well but this is one of the simplest methods.


    Wednesday, March 4, 2015 3:01 PM