I have a simple function to get data:
Function GetAppro(Current_Sheet As String)
Dim myArray As Variant
myArray = Worksheets(Current_Sheet).Range("A3:C6")
GetAppro = myArray
End Function
And other funtion to get other data:
Function GetTabs()
Dim Get_Tabs_generated(2) As String
Get_Tabs_generated(0) = "AA"
Get_Tabs_generated(1) = "BB"
Get_Tabs_generated(2) = "CC"
GetTabs = Get_Tabs_generated
End Function
In my final procedure i do:
Sub GenerateDB()
Dim Appro() As String
Dim Tabs() As String
'Init
Tabs = GetTabs()
For Each Tabs_item In Tabs
Appro = GetAppro(Tabs_item.Value)
MsgBox Appro(0, 0)
Next Tabs_item
End Sub
Excel say me compile error Object required (Error 424). I am novice with functions
答案 0 :(得分:0)
<强>解决方案:强> 不要忘记CStr()
Sub GenerateDB()
Dim Appro() As String
Dim Tabs() As String
'Init
Tabs = GetTabs()
For Each Tabs_item In Tabs
Appro = GetAppro(CStr(Tabs_item))
MsgBox Appro(0, 0)
Next Tabs_item
End Sub
特别感谢@ScottCraner