excel – findramdomly位置的值和单元格返回值左边

我需要在名为“data”的工作表上find多个随机定位的值“windows_group”的实例,并将单元格的值返回到“windows_group”单元格左侧的另一个工作表“Windows_Groups”中。

工作表“数据”只有AG列中的数据,但最多可以有5000行。

先谢谢你!

这样做可能会更加优雅,但是一种powershell的方式是通过单元格循环并使用偏移量方法的macros:

sub FindAndReturn() 'I'm not good at naming dim cell as range dim i as integer dim k as integer k = 1 for each cell in Worksheets("Data").Range("B1:G5000") ' i'm assuming this has to start in column B if you want the value to the left if cell.value = "windows_group" Then Worksheets("Windows_Groups").Range("A" & k).Value = cell.offset(0,-1).value k=k+1 End if next cell end sub