在多列中进行excel查找

我希望有人可以帮助我认为是一个简单的任务。

我有一个工作表(Sheet1)有很多列。 前两个分别是一个数字和一个名字。 在这两列之后,每列有不同的列数(例如第一列有10列,第二列有4列等)。

我有另一个工作表(Sheet2)与2列。 第一列有一个我想在Sheet1中查找的值。 问题是这个值可能在Sheet2的列的前两列之后的任何地方(例如,查找值123,值在列13行6或查找值456在列5行14)然后我想要在Sheet1上的列1行6放入Sheet2的列2中。

我曾尝试使用Vlookup,Hlookup和查找,但似乎无法弄清楚如何得到它的工作。

任何帮助将非常感激

谢谢Gareth

…我知道你没有要求VBA解决scheme,但我只是想写一个,看看我会怎么做…

我做了“快速和肮脏”没有任何错误检查等,但它会给你你在找什么:

Public Function FindInRange(Val As Variant, LookIn As Range, ColIndexNumber As Integer) As Range ' INPUTS: ' Val = The Value you're looking for in your Range of cells ' Range = The range of cells you're searching through ' ColIndexNumber = The index of the column you want a value returned from within the row from which the value is found ' NOTE: ' This will only pull the first value matching your "Val" argument Dim FoundCell As Range Set FoundCell = LookIn.Find(what:=Val, LookAt:=xlWhole) If FoundCell Is Nothing Then Set FindInRange = Nothing Else Set FindInRange = Intersect(LookIn.Columns(ColIndexNumber), FoundCell.EntireRow) End If End Function 

如果你把它粘贴到一个VBA模块中,你可以像电子表格一样在你的电子表格中调用它。

希望这可以帮助 :)