Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Loops to compare many rows between 2 worksheets in C#?

  1. Jun 19, 2012 #1
    Hello All,

    I took it upon myself to create a tool for my job that xref 2 excel worksheets on 2 different workbooks. Customers send us parts and they're wanting the leadtimes for them. We have a weekly report that has all part numbers with their leadtimes. My goal is to create a GUI in C# that my team can copy & paste the customer's requested part numbers into a control, then click a button that generates a new excel file with those pasted parts in the 1st column. While simultaneously have the weekly report opened in the background. Compare each row of customer parts with the weekly report and if there's a match, provide it's respective leadtime number in column B. The only thing I have figured out so far is to open the workbooks and name the worksheet.(whoopty doo)

    My issues so far:

    1. What control to use in my windows form that can hold a varying number of part numbers? I know a rich textbox has limits. The number of parts a customer sends us vary. One could send in 50 part numbers, and someone else could send 2000 parts.

    2. What type of loop should be used to compare 2 columns on 2 different worksheets, and provide their respective row of info?

    In theory this seemed pretty straight forward and not that difficult, but it seems like working with Interop.Excel gets pretty messy. Looks like I've dug myself a deep hole. I would really appreciate any input that you may have.

    Thanks in advance!!!
  2. jcsd
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted