|
■No99563 (栄久世留白音 さん) に返信
変数とかシートの値とかがおかしいんじゃないですかね、わからないですけど
Office365ではこれで動きました
Sub Main()
Dim a As Variant
ReDim a(2, 0)
a(0, 0) = "a"
a(1, 0) = "b"
a(2, 0) = "c"
Sheet1.Range("A2:A4").Value = a
Dim b As Variant
ReDim b(2, 0)
b(0, 0) = 1
b(1, 0) = 2
b(2, 0) = 3
Sheet2.Range("A2:A4").Value = b
Debug.Print func("a")
Debug.Print func("b")
Debug.Print func("c")
End Sub
Function func(name As String) As Long
Dim irowno As Long
Dim Var As Variant
Var = Sheet1.Range("A2:A4").Value
For irowno = 2 To UBound(Var, 1)
If Sheet1.Cells(irowno, 1) = name Then
Exit For
End If
Next
func = Sheet2.Cells(irowno, 1)
End Function
|