返回列表 上一主題 發帖

如何抓取對應資料

回復 7# kimbal
板主的公式=INDEX(Sheet1!$C$2:$G$8,MATCH(B2,Sheet1!$B$1:$B$8,1),MATCH(Sheet2!A2,Sheet1!C$1:G$1,0))會有差異
當B欄是80, 100,120,140,160,180 傳回的是下一列的值
當B欄是200時 則會超出範圍 =#REF!
回復 1# baomin
依1樓 SHEET2.JPG 圖表 所寫的自訂函數   請將程式碼複製到 一般模組中(Module)使用
  1. '傳回 模數所對應到秒數的數據  範圍必需包含模數列  秒數列
  2. Function Ex(範圍 As Range, 模數 As String, 秒數 As Integer) As Integer
  3.     Dim C As Range, Row%, Col%
  4.     If Not 範圍.Rows(1).Find(模數, LookIn:=xlValues, LOOKAT:=xlWhole) Is Nothing Then
  5.         Col = 範圍.Rows(1).Find(模數, LookIn:=xlValues, LOOKAT:=xlWhole).Column
  6.     End If
  7.     For Each C In 範圍.Columns(1).Cells
  8.          If C.Row > 1 Then
  9.             If Val(Split(C, "~")(0)) <= 秒數 And Val(Split(C, "~")(1)) >= 秒數 Then
  10.                 Row = C.Row
  11.                 Exit For
  12.             End If
  13.         End If
  14.     Next
  15.     If Row > 0 And Col > 0 Then Ex = Sheets(範圍.Parent.Name).Cells(Row, Col)
  16. End Function
複製代碼

TOP

        靜思自在 : 【時間如鑽石】時間對一個有智慧的人而言,就如鑽石般珍貴;但對愚人來說,卻像是一把泥土,一點價值也沒有。
返回列表 上一主題